Kristin Vernon
Kristin Vernon

Reputation: 155

flutter - ERROR: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

When running flutter build apk I get the following:

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50/50ad05ea1c2595fb31b800e76db464d08d599af3/kotlin-stdlib-jdk7-1.3.50.jar (version 1.3)
    C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50/b529d1738c7e98bbfa36a4134039528f2ce78ebf/kotlin-stdlib-1.3.50.jar (version 1.3)
    C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50/3d9cd3e1bc7b92e95f43d45be3bfbcf38e36ab87/kotlin-stdlib-common-1.3.50.jar (version 1.3)
    C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar (version 1.5)
    C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar (version 1.5)
    C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

I have already done some of the suggestions I've found online and in this group but so far nothing have worked. In android\build.gradle:

buildscript {
    ext.kotlin_version = '1.5.10'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
        classpath "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.10"
        classpath "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"

    }
}

And in app\build.gradle:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.10"
}

I've also ran flutter pub upgrade --major-versions

I've been able to build my apk no problem before, I added workmanager to my pubsec.yaml and this issue started coming up, however I removed the package and the issue still persists. Any help appreciated I've been stuck on this for awhile!

Output of flutter doctor -v

[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19041.1288], locale en-BZ)
    • Flutter version 2.2.2 at C:\flutter
    • Framework revision d79295af24 (4 months ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\username\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.8+10-b944.6842174)

[√] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1.2
    • Flutter plugin version 57.0.5
    • Dart plugin version 211.7665

[√] VS Code (version 1.59.1)
    • VS Code at C:\Users\kvernon\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.81
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 94.0.992.47

• No issues found!

Upvotes: 7

Views: 12754

Answers (4)

Kristin Vernon
Kristin Vernon

Reputation: 155

Came back to this after having the same problem and couldn't figure out what I did the first time but basically I needed to figure out how to upgrade the gradle version in android/app/build.gradle: classpath 'com.android.tools.build:gradle:7.3.1' (I had this on 4.2.2)

Then I had to make the same update in android/gradle/wrapper/gradle-wrapper.properties like so distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

Then built with no errors.

Upvotes: 2

Ramananda Panda
Ramananda Panda

Reputation: 55

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: 4

Christian Grandez
Christian Grandez

Reputation: 336

use

ext.kotlin_version = '1.6.10'

and Change jdk7 to Java jdk8

before

dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

after

dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

Upvotes: 17

Ivan
Ivan

Reputation: 114

I got the same problem after installing the qr_code_scanner, and changing biuld.gradle as described here: https://pub.dev/packages/qr_code_scanner

than I got warnings from build apk

w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.61/70dffc5f8ac5ea7c34f30deac5b9d8b1d48af066/kotlin-stdlib-jdk7-1.3.61.jar (version 1.3)
    /home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.61/4702105e97f7396ae41b113fdbdc180ec1eb1e36/kotlin-stdlib-1.3.61.jar (version 1.3)
    /home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.61/65abb71d5afb850b68be03987b08e2c864ca3110/kotlin-stdlib-common-1.3.61.jar (version 1.3)
    /home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar (version 1.5)
    /home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar (version 1.5)
    /home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

so, I remove that lib and undo my changes, and that fix it.

If workmanager change your build.gradle and gradle-wrapper.properties, you probably should change it back to previous version.

Upvotes: 0

Related Questions