compileDebugJavaWithJavac task (current target it 1.8) and kaptGenerateStubsDebugKotlin task...
这个错误提示 “compileDebugJavaWithJavac task (current target is 1.8) and kaptGenerateStubsDebugKotlin task (current target is 17)” 表示在执行 compileDebugJavaWithJavac 任务时,Java 的编译目标版本为 1.8,而在执行 kaptGenerateStub
文章共249字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
compileDebugJavaWithJavac task (current target it 1.8) and kaptGenerateStubsDebugKotlin task (current target is 17)
这个错误提示 “compileDebugJavaWithJavac task (current target is 1.8) and kaptGenerateStubsDebugKotlin task (current target is 17)” 表示在执行 compileDebugJavaWithJavac 任务时,Java 的编译目标版本为 1.8,而在执行 kaptGenerateStubsDebugKotlin 任务时,Kotlin 的编译目标版本为 17,它们应该设置为相同的版本。
由于较新版本的Android Studio 的默认jdk变成了17,所以当我们在配置像Glide 编译器这类问题时,如果需要配置kotlin-kapt 插件,就会报错。
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}
解决方法
build.gradle(:app)
android {
// ...
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
更多推荐
已为社区贡献2条内容
所有评论(0)