【发布时间】:2019-07-25 02:34:12
【问题描述】:
尝试编译用 kotlin 编写的单元测试时出现以下错误。
Task :app:compileDebugUnitTestKotlin FAILED ...Cannot inline bytecode built with JVM target 1.7 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
我已尝试在我的应用程序build.gradle 中为我的android 配置设置源兼容性:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
以及在根build.gradle中配置所有kotlin编译任务:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = '1.8'
}
}
【问题讨论】:
-
@ZeroDivide 你能把这个stackoverflow.com/a/58094987/5040556标记为正确答案吗