我当前的 Android 项目显示以下构建消息:-
> Task :shared:resource:kaptGenerateStubsProductionDebugKotlin
'compileProductionDebugJavaWithJavac' task (current target is 17) and 'kaptGenerateStubsProductionDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: https://kotl.in/gradle/jvm/target-validation
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
Run Code Online (Sandbox Code Playgroud)
如何配置 kapt 在特定版本的 java 中生成存根?
我努力了...
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs).configureEach {
kotlinJavaToolchain.jdk.use(
"/usr/local/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home",
JavaVersion.VERSION_17
)
}
Run Code Online (Sandbox Code Playgroud)
和
kapt {
javacOptions {
option("--target", 17)
}
}
Run Code Online (Sandbox Code Playgroud)
这些都没有任何区别
是否可以控制 Android 项目中 kapt 生成的存根的 java 版本?
在 kapt3 中启用详细日志记录后,我现在可以看到我已正确配置目标 …