The error you are getting means that there's no compileKotlin
task in the project, and that's expected for Android projects.
The Kotlin compilation task names in Android projects contain the build variant names (those are combined from build type, product flavor and other settings and look like debug
or releaseUnitTest
-- the tasks are compileDebugKotlin
and compileReleaseUnitTestKotlin
respectively). There's no compileKotlin
task, which is usually created for the main
source set in ordinary Java + Kotlin projects.
Most probably, you want to configure all Kotlin compilation tasks in the project, and to do that, you can apply the block as follows:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = '1.8'
apiVersion = '1.1'
languageVersion = '1.1'
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…