当前位置:   article > 正文

Androidstudio current target is 1.8 and ‘compileDebugKotlin‘ task (current target is 11)_this project is configured to use an older gradle

this project is configured to use an older gradle jvm that supports up to ve

升级AGP8.2.2

项目升级AGP,导致变异错误

* What went wrong:
Execution failed for task ':base:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
  • 1
  • 2
  • 3
  • 4

尝试降低到1.8

把所有配置修改成1.8

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
  • 1
  • 2
  • 3
  • 4

编译项目得到新的错误:

This project is configured to use an older Gradle JVM that supports up to version 11 but the current AGP requires a Gradle JVM that supports version 17.
  • 1

也就是新as和AGP需要更高版本的jvm配置了。

解决方案

打开as设置,编译jvm设置17.
在这里插入图片描述
项目中使用到kotlin的模块设置:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}
  • 1
  • 2
  • 3
  • 4

同步项目,即可解决问题。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/639929
推荐阅读
相关标签
  

闽ICP备14008679号