[Flutter] Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.


問題描述:

Android Studio在更新完gradle后,發現demo項目運行出錯了。

報錯有一大串(很多文件),一直在重復說着要我提高gradle版本。

看下報錯信息:

 
         

The class is loaded from C:/Users/samsung/.gradle/caches/transforms-3/7ad36a5b116dac2d2ae0e1e5f4e80713/transformed/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class
e: D:\Flutter\flutter\.pub-cache\hosted\pub.flutter-io.cn\wakelock-0.6.1+1\android\src\main\kotlin\creativemaybeno\wakelock\WakelockPlugin.kt: (30, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15

.....
.....
.....

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':wakelock:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 20s
[!] Your project requires a newer version of the Kotlin Gradle plugin.
    Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update D:\Flutter\Code\flutter_demo\android\build.gradle:
    ext.kotlin_version = '<latest-version>'
Exception: Gradle task assembleDebug failed with exit code 1
  

其中,從這三句可以看到原因和解決方法:

The class is loaded from C:/Users/samsung/.gradle/caches/transforms-3/7ad36a5b116dac2d2ae0e1e5f4e80713/transformed/jetified-kotlin-stdlib-1.5.31.jar!/kotlin/Unit.class 
The binary version of its metadata is 1.5.1, expected version is 1.1.15.
[!] Your project requires a newer version of the Kotlin Gradle plugin.
update D:\Flutter\Code\flutter_demo\android\build.gradle:

解決方法:

找到項目下的\android\build.gradle文件

修改Kotlin_version為報錯信息中最高的版本,即1.5.31

ext.kotlin_version = '1.5.31'

 

完畢!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM