flutter build apk - 类路径中的运行时 JAR 文件应该具有相同的版本

Yog*_*odo 0 java android gradle kotlin flutter

类似的问题flutter build 类路径中的运行时 JAR 文件应该具有相同的版本。这些文件在类路径中找到

\n

仅解决了新项目/sf/answers/4995393581/,但当我尝试旧项目时,错误仍然存​​在。我也尝试过flutter clean重新启动设备

\n
\xe2\x9e\x9c  xxxx git:(master) \xe2\x9c\x97 flutter build apk --release      \n\n Building with sound null safety \n\nw: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.6.10/e80fe6ac3c3573a80305f5ec43f86b829e8ab53d/kotlin-stdlib-jdk8-1.6.10.jar (version 1.6)\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.7.10/1ef73fee66f45d52c67e2aca12fd945dbe0659bf/kotlin-stdlib-jdk7-1.7.10.jar (version 1.7)\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar (version 1.7)\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.10/bac80c520d0a9e3f3673bc2658c6ed02ef45a76a/kotlin-stdlib-common-1.7.10.jar (version 1.7)\nw: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath\ne: /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.7.10/1ef73fee66f45d52c67e2aca12fd945dbe0659bf/kotlin-stdlib-jdk7-1.7.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.\ne: /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.\ne: /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.10/bac80c520d0a9e3f3673bc2658c6ed02ef45a76a/kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.\nw: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.6.10/e80fe6ac3c3573a80305f5ec43f86b829e8ab53d/kotlin-stdlib-jdk8-1.6.10.jar (version 1.6)\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.7.10/1ef73fee66f45d52c67e2aca12fd945dbe0659bf/kotlin-stdlib-jdk7-1.7.10.jar (version 1.7)\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.7.10/d2abf9e77736acc4450dc4a3f707fa2c10f5099d/kotlin-stdlib-1.7.10.jar (version 1.7)\n    /Users/yogiarifwidodo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.10/bac80c520d0a9e3f3673bc2658c6ed02ef45a76a/kotlin-stdlib-common-1.7.10.jar (version 1.7)\nw: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath\nRunning Gradle task \'assembleRelease\'...                           22.3s\n\xe2\x9c\x93  Built build/app/outputs/flutter-apk/app-release.apk (25.7MB).\n
Run Code Online (Sandbox Code Playgroud)\n

我的配置

\n
/x/android/build.gradle\n\next.kotlin_version = \'1.6.10\'\n...\n...\n    dependencies {\n        classpath \'com.android.tools.build:gradle:7.1.2\'\n        // START: FlutterFire Configuration\n        classpath \'com.google.gms:google-services:4.3.10\'\n        classpath \'com.google.firebase:firebase-crashlytics-gradle:2.8.1\'\n        // END: FlutterFire Configuration\n        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n    }\n...\n...\n/x/android/gradle/wrapper/gradle-wrapper.properties\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip\n...\n...\n/x/android/app/build.gradle\ndependencies {\n    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我的引擎

\n
\xe2\x9e\x9c  first_app flutter doctor -v\n[\xe2\x9c\x93] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-ID)\n    \xe2\x80\xa2 Flutter version 3.0.5 at /Users/yogiarifwidodo/dev/flutter\n    \xe2\x80\xa2 Upstream repository https://github.com/flutter/flutter.git\n    \xe2\x80\xa2 Framework revision f1875d570e (8 weeks ago), 2022-07-13 11:24:16 -0700\n    \xe2\x80\xa2 Engine revision e85ea0e79c\n    \xe2\x80\xa2 Dart version 2.17.6\n    \xe2\x80\xa2 DevTools version 2.12.2\n\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 30.0.3)\n    \xe2\x80\xa2 Android SDK at /Users/yogiarifwidodo/Library/Android/sdk\n    \xe2\x80\xa2 Platform android-33, build-tools 30.0.3\n    \xe2\x80\xa2 ANDROID_HOME = /Users/yogiarifwidodo/Library/Android/sdk\n    \xe2\x80\xa2 Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)\n    \xe2\x80\xa2 All Android licenses accepted.\n\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 13.3)\n    \xe2\x80\xa2 Xcode at /Applications/Xcode.app/Contents/Developer\n    \xe2\x80\xa2 CocoaPods version 1.11.0\n\n[\xe2\x9c\x93] Chrome - develop for the web\n    \xe2\x80\xa2 Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome\n\n[\xe2\x9c\x93] Android Studio (version 2021.2)\n    \xe2\x80\xa2 Android Studio at /Applications/Android Studio.app/Contents\n    \xe2\x80\xa2 Flutter plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/9212-flutter\n    \xe2\x80\xa2 Dart plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/6351-dart\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)\n\n[\xe2\x9c\x93] VS Code (version 1.72.0-insider)\n    \xe2\x80\xa2 VS Code at /Applications/Visual Studio Code - Insiders.app/Contents\n    \xe2\x80\xa2 Flutter extension version 3.48.0\n\n[\xe2\x9c\x93] Connected device (2 available)\n    \xe2\x80\xa2 macOS (desktop) \xe2\x80\xa2 macos  \xe2\x80\xa2 darwin-arm64   \xe2\x80\xa2 macOS 12.4 21F79 darwin-arm\n    \xe2\x80\xa2 Chrome (web)    \xe2\x80\xa2 chrome \xe2\x80\xa2 web-javascript \xe2\x80\xa2 Google Chrome 104.0.5112.101\n\n[\xe2\x9c\x93] HTTP Host Availability\n    \xe2\x80\xa2 All required HTTP hosts are available\n\n\xe2\x80\xa2 No issues found!\n
Run Code Online (Sandbox Code Playgroud)\n
\xe2\x9e\x9c  JavaVirtualMachines ll\ntotal 0\ndrwxr-xr-x  3 root  wheel    96B Jun 27  2021 zulu-11.jdk\ndrwxr-xr-x  3 root  wheel    96B Sep  3 11:58 zulu-17.jdk\ndrwxr-xr-x  3 root  wheel    96B May  1  2021 zulu-8.jdk\n\xe2\x9e\x9c  JavaVirtualMachines pwd\n/Library/Java/JavaVirtualMachines\n
Run Code Online (Sandbox Code Playgroud)\n

ant*_*nit 6

我有完全相同的问题。这是我修复它的方法:

  1. 将Kotlin版本升级1.7.10android/app/build.gradle. 应该看起来像这样ext.kotlin_version = '1.7.10'
  2. Android Gradle 插件升级到. 应该看起来像这样7.3.0android/app/build.gradleclasspath 'com.android.tools.build:gradle:7.3.0'
  3. 在终端中导航到 android 文件夹cd android并运行以将Gradle./gradlew wrapper --gradle-version=7.5.1版本升级到. 这将更改分发 url 以指向正确的 gradle 分发。7.5.1android/gradle/wrapper/gradle-wrapper.properties
  4. 删除文件夹android/.gradleflutter clean在终端中运行
  5. 运行您的应用程序,警告应该就会消失。

为了便于将来参考,这里是查找Android Gradle 插件Gradle支持的组合的好地方:https: //developer.android.com/studio/releases/gradle-plugin

按照建议简单地替换jdk7jdk8in android/app/build.gradle,对我来说不起作用。事实上,最好完全删除此依赖项,因为它是由Android Gradle 插件默认添加的。参考: https: //github.com/flutter/flutter/issues/101373