e: Incompatible classes were found in dependencies. Remove them from the classpath or use ‘-Xskip-me

文章描述了在尝试运行Flutter项目时遇到的编译错误,错误涉及Kotlin版本不兼容问题。解决方案是更新Android项目的build.gradle文件中的kotlin_version至兼容的版本,例如从1.5.21升级到1.6.21,从而解决依赖库中的类版本冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值