skip to Main Content

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

2

Answers


  1. 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"
    
    Login or Signup to reply.
  2. I had the exact same issue. Here is how I fixed it:

    1. Upgrade the Kotlin version to 1.7.10 in android/app/build.gradle. Should look like this ext.kotlin_version = '1.7.10'
    2. Upgrade the Android Gradle plugin to 7.3.0 in android/app/build.gradle. Should look like this classpath 'com.android.tools.build:gradle:7.3.0'
    3. In the terminal navigate to the android folder 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.
    4. Delete the folder android/.gradle and run flutter clean in the terminal
    5. Run your app and the warnings should be gone.

    For 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search