类路径中的 flutter build Runtime JAR 文件应该具有相同的版本。这些文件在类路径中找到

lat*_*day 35 android dart flutter

类路径中的 flutter build Runtime JAR 文件应该具有相同的版本。这些文件在类路径中找到

\n

我怎么解决这个问题

\n
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar (version 1.5)\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.6.10/e1c380673654a089c4f0c9f83d0ddfdc1efdb498/kotlin-stdlib-jdk7-1.6.10.jar (version 1.6)\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.10/b8af3fe6f1ca88526914929add63cf5e7c5049af/kotlin-stdlib-1.6.10.jar (version 1.6)\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.10/c118700e3a33c8a0d9adc920e9dec0831171925/kotlin-stdlib-common-1.6.10.jar (version 1.6)\nw: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath\nw: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.30/5fd47535cc85f9e24996f939c2de6583991481b0/kotlin-stdlib-jdk8-1.5.30.jar (version 1.5)\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.6.10/e1c380673654a089c4f0c9f83d0ddfdc1efdb498/kotlin-stdlib-jdk7-1.6.10.jar (version 1.6)\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.10/b8af3fe6f1ca88526914929add63cf5e7c5049af/kotlin-stdlib-1.6.10.jar (version 1.6)\n    C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.10/c118700e3a33c8a0d9adc920e9dec0831171925/kotlin-stdlib-common-1.6.10.jar (version 1.6)\nw: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath\n
Run Code Online (Sandbox Code Playgroud)\n

应用程序构建等级设置

\n
def localProperties = new Properties()\ndef localPropertiesFile = rootProject.file('local.properties')\nif (localPropertiesFile.exists()) {\n    localPropertiesFile.withReader('UTF-8') { reader ->\n        localProperties.load(reader)\n    }\n}\n\ndef flutterRoot = localProperties.getProperty('flutter.sdk')\nif (flutterRoot == null) {\n    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")\n}\n\ndef flutterVersionCode = localProperties.getProperty('flutter.versionCode')\nif (flutterVersionCode == null) {\n    flutterVersionCode = '1'\n}\n\ndef flutterVersionName = localProperties.getProperty('flutter.versionName')\nif (flutterVersionName == null) {\n    flutterVersionName = '1.0'\n}\n\napply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"\n\ndef keystoreProperties = new Properties()\ndef keystorePropertiesFile = rootProject.file('key.properties')\nif (keystorePropertiesFile.exists()) {\n    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))\n}\n\n// crashlytics\napply plugin: 'com.google.gms.google-services'\napply plugin: 'com.google.firebase.crashlytics'\n\nandroid {\n    compileSdkVersion 31\n\n    sourceSets {\n        main.java.srcDirs += 'src/main/kotlin'\n    }\n\n    defaultConfig {\n        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).\n        applicationId "com.example.mower_app"\n        minSdkVersion 21\n        targetSdkVersion 31\n        versionCode flutterVersionCode.toInteger()\n        versionName flutterVersionName\n    } \n    signingConfigs {\n       release {\n           keyAlias keystoreProperties['keyAlias']\n           keyPassword keystoreProperties['keyPassword']\n           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null\n           storePassword keystoreProperties['storePassword']\n       }\n    }\n    buildTypes {\n        release {\n            signingConfig signingConfigs.release\n            // \xe5\x90\xaf\xe7\x94\xa8\xe7\x94\xb1Android Gradle\xe6\x8f\x92\xe4\xbb\xb6\xe6\x89\xa7\xe8\xa1\x8c\xe7\x9a\x84\xe8\xb5\x84\xe6\xba\x90\xe6\x94\xb6\xe7\xbc\xa9\n            minifyEnabled true \n            shrinkResources true \n            firebaseCrashlytics {\n                mappingFileUploadEnabled true\n            }\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\nflutter {\n    source '../..'\n}\n\ndependencies {\n    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"\n    implementation platform('com.google.firebase:firebase-bom:29.0.3')\n    implementation 'com.google.firebase:firebase-analytics-ktx'\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

android > 构建.等级

\n
buildscript {\n    ext.kotlin_version = '1.6.10'\n    repositories {\n        google()\n        jcenter()\n    }\n\n    dependencies {\n        // crashlytics\n        classpath 'com.google.gms:google-services:4.3.10'\n        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'\n        classpath 'com.android.tools.build:gradle:7.1.2'\n        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n    }\n}\n\nallprojects {\n    repositories {\n        google()\n        jcenter()\n    }\n}\n\nrootProject.buildDir = '../build'\nsubprojects {\n    project.buildDir = "${rootProject.buildDir}/${project.name}"\n    project.evaluationDependsOn(':app')\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n
Run Code Online (Sandbox Code Playgroud)\n

如何解决此问题\n每次 FLUTTER 构建时都会出现此问题\nflutter 2.10.1\nDart SDK 版本:2.16.1(稳定)(2022 年 2 月 8 日星期二 12:02:33 +0100)在“windows_x64”上

\n

51v*_*1v4 102

app/build.gradlejdk7更改为Java jdk8

dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)

dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)

  • 仍然有错误(同样的问题), (6认同)

小智 20

仅51v4 获得最多支持的答案对我来说不起作用
结合他的答案和@anton-definit的答案,我得到了适合我的解决方案。没有显示任何警告消息。

  1. jdk版本从升级jdk7到. 应该看起来像这样jdk8android/build.gradle
dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
Run Code Online (Sandbox Code Playgroud)
  1. 将Kotlin版本升级1.7.10android/build.gradle. 应该看起来像这样ext.kotlin_version = '1.7.10'

  2. Android Gradle 插件升级到. 应该看起来像这样7.3.0android/build.gradleclasspath 'com.android.tools.build:gradle:7.3.0'

  3. 将Gradle版本升级7.5.1android/gradle/wrapper/gradle-wrapper.properties. 应该看起来像这样。distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip

  4. 删除文件夹C:\Users\[user_name_here]\.gradle。如果删除文件夹时遇到任何错误.gradle,请打开Windows 任务管理器并终止OpenJDK 平台二进制文件,然后重试删除。flutter clean最后在终端运行。

  5. 运行您的应用程序。耐心等待,重新安装 gradle 包装器和设置将需要 10 多分钟,并且flutter build apk将在没有警告的情况下完成。