flutter 点击pubspec.yaml 里的 Pub get正常,运行项目时报错
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/Admin/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/META-INF/annotation.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: C:/Users/Admin/.gradle/caches/transforms-2/files-2.1/234e98c0fda29ce2f06c3a0522f12d5a/jetified-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: C:/Users/Admin/.gradle/caches/transforms-2/files-2.1/b9b1da7b9cbc5349203b184dee10247b/jetified-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.
e: D:\flutterWorkSpace\atuiflutter\android\app\src\main\kotlin\cn\adazon\atui\MainActivity.kt: (5, 28): Class 'androidx.annotation.NonNull' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from C:/Users/Admin/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/androidx/annotation/NonNull.class
e: D:\flutterWorkSpace\atuiflutter\android\app\src\main\kotlin\cn\adazon\atui\MainActivity.kt: (15, 42): Class 'androidx.annotation.NonNull' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from C:/Users/Admin/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.5.0/857678d6b4ca7b28571ef7935c668bdb57e15027/annotation-1.5.0.jar!/androidx/annotation/NonNull.class
e: D:\flutterWorkSpace\atuiflutter\android\app\src\main\kotlin\cn\adazon\atui\MainActivity.kt: (16, 35): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from C:/Users/Admin/.gradle/caches/transforms-2/files-2.1/234e98c0fda29ce2f06c3a0522f12d5a/jetified-kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: D:\flutterWorkSpace\atuiflutter\android\app\src\main\kotlin\cn\adazon\atui\MainActivity.kt: (23, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from C:/Users/Admin/.gradle/caches/transforms-2/files-2.1/234e98c0fda29ce2f06c3a0522f12d5a/jetified-kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
e: D:\flutterWorkSpace\atuiflutter\android\app\src\main\kotlin\cn\adazon\atui\MainActivity.kt: (32, 20): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The class is loaded from C:/Users/Admin/.gradle/caches/transforms-2/files-2.1/234e98c0fda29ce2f06c3a0522f12d5a/jetified-kotlin-stdlib-1.7.10.jar!/kotlin/Unit.class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
翻译过来: 在依赖项中发现了不兼容的类。从类路径中删除它们,或者使用“-Xskip元数据版本检查”来抑制错误
查过自己的依赖库,啥也没看出来。在信息里看到kotlin,想着是不是可以改一下kotlin版本试试
打开:android>build.gradle
项目里原本的是:ext.kotlin_version = ‘1.5.21’ 改成ext.kotlin_version = ‘1.6.21’ 成功运行起来了
Android原生项目出现这个问题应该也能这样解决吧
可以在这个链接里查看kotlin_version