Reputation: 679
similar issue flutter build Runtime JAR files in the classpath should have the same version. These files were found in the classpath
solved only for new project https://stackoverflow.com/a/71362765/8122500 but when i tried on old project, the error is still facing on me. also i have tried with flutter clean, restart device, etc
ā xxxx git:(master) ā flutter build apk --release
šŖ Building with sound null safety šŖ
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/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)
/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)
/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)
/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)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
e: /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.
e: /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.
e: /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.
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/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)
/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)
/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)
/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)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
Running Gradle task 'assembleRelease'... 22.3s
ā Built build/app/outputs/flutter-apk/app-release.apk (25.7MB).
my configuration
/x/android/build.gradle
ext.kotlin_version = '1.6.10'
...
...
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
...
...
/x/android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
...
...
/x/android/app/build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
my engine
ā first_app flutter doctor -v
[ā] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-ID)
ā¢ Flutter version 3.0.5 at /Users/yogiarifwidodo/dev/flutter
ā¢ Upstream repository https://github.com/flutter/flutter.git
ā¢ Framework revision f1875d570e (8 weeks ago), 2022-07-13 11:24:16 -0700
ā¢ Engine revision e85ea0e79c
ā¢ Dart version 2.17.6
ā¢ DevTools version 2.12.2
[ā] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
ā¢ Android SDK at /Users/yogiarifwidodo/Library/Android/sdk
ā¢ Platform android-33, build-tools 30.0.3
ā¢ ANDROID_HOME = /Users/yogiarifwidodo/Library/Android/sdk
ā¢ Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
ā¢ Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
ā¢ All Android licenses accepted.
[ā] Xcode - develop for iOS and macOS (Xcode 13.3)
ā¢ Xcode at /Applications/Xcode.app/Contents/Developer
ā¢ CocoaPods version 1.11.0
[ā] Chrome - develop for the web
ā¢ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[ā] Android Studio (version 2021.2)
ā¢ Android Studio at /Applications/Android Studio.app/Contents
ā¢ Flutter plugin can be installed from:
šØ https://plugins.jetbrains.com/plugin/9212-flutter
ā¢ Dart plugin can be installed from:
šØ https://plugins.jetbrains.com/plugin/6351-dart
ā¢ Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[ā] VS Code (version 1.72.0-insider)
ā¢ VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
ā¢ Flutter extension version 3.48.0
[ā] Connected device (2 available)
ā¢ macOS (desktop) ā¢ macos ā¢ darwin-arm64 ā¢ macOS 12.4 21F79 darwin-arm
ā¢ Chrome (web) ā¢ chrome ā¢ web-javascript ā¢ Google Chrome 104.0.5112.101
[ā] HTTP Host Availability
ā¢ All required HTTP hosts are available
ā¢ No issues found!
ā JavaVirtualMachines ll
total 0
drwxr-xr-x 3 root wheel 96B Jun 27 2021 zulu-11.jdk
drwxr-xr-x 3 root wheel 96B Sep 3 11:58 zulu-17.jdk
drwxr-xr-x 3 root wheel 96B May 1 2021 zulu-8.jdk
ā JavaVirtualMachines pwd
/Library/Java/JavaVirtualMachines
Upvotes: 0
Views: 2990
Reputation: 81
I had the exact same issue. Here is how I fixed it:
1.7.10
in android/app/build.gradle
. Should look like this ext.kotlin_version = '1.7.10'
7.3.0
in android/app/build.gradle
. Should look like this classpath 'com.android.tools.build:gradle:7.3.0'
cd android
and run ./gradlew wrapper --gradle-version=7.5.1
to upgrade the Gradle version to 7.5.1
. This will change the distribution url in android/gradle/wrapper/gradle-wrapper.properties
to point to the correct gradle distribution.android/.gradle
and run flutter clean
in the terminalFor future reference, a good place to find the supported combinations of the Android Gradle plugin and Gradle is here: https://developer.android.com/studio/releases/gradle-plugin
Simply replacing jdk7
with jdk8
in android/app/build.gradle
as suggested, did not work for me. In fact, it could be best to just remove this dependency altogether because it is added by default by the Android Gradle plugin. Reference: https://github.com/flutter/flutter/issues/101373
Upvotes: 6
Reputation: 724
It works for me to replace jdk7 with jdk8 in app/build.gradle file under the dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
with
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Upvotes: 1