java - flutter - 错误 : Some runtime JAR files in the classpath have an incompatible version. 考虑将它们从类路径中删除

标签 java android flutter kotlin intellij-idea

运行flutter build apk时,我得到以下信息:

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
我已经完成了一些我在网上和这个小组中找到的建议,但到目前为止没有任何效果。在 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"

    }
}
在 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"
}
我也跑过 flutter pub upgrade --major-versions
我之前能够构建我的 apk 没有问题,我将 workmanager 添加到我的 pubsec.yaml 并且这个问题开始出现,但是我删除了包并且问题仍然存在。任何帮助表示赞赏我已经坚持了一段时间!
flutter 医生 -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!

最佳答案

利用

ext.kotlin_version = '1.6.10'
并将 jdk7 更改为 Java jdk8
dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

关于java - flutter - 错误 : Some runtime JAR files in the classpath have an incompatible version. 考虑将它们从类路径中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69653870/

相关文章:

java - 如何使用 Hashmap 在 firebase firestore android 中添加 Map<String, Object> 元素?商店数据库

android - 在 Activity 中从一个 fragment 移动到另一个 fragment

json - Flutter:JSON 响应不完整

dart - Flutter Renderboxes 传递 Infinity 高度?

Flutter:RichText 不适用于主题

java - Websphere MQ 检查对象是否存在

java - 如何添加过滤功能?

java - 在 Quarkus 中重定向到 https

java - 创建 bean 时出错 "entityManagerFactory"

android - YouTube 视频列表方法显示错误