当前位置: 首页 > 知识库问答 >
问题:

未解析的引用:build.gradle.kts中的compileKotlin

鞠晋
2023-03-14
compileKotlin {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
compileTestKotlin {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
 plugins {
    kotlin("jvm") version "1.2.10"
    id("application")
}

group = "com.myproject"
version = "1.0-SNAPSHOT"

application {
    mainClassName = "MainKt"
}

java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
    jcenter()
}

val kotlinVer = "1.2.10"

dependencies {
    compile(kotlin(module = "stdlib-jre8", version = kotlinVer))
    implementation("com.google.code.gson:gson:2.7")
    implementation("com.squareup.okhttp3:logging-interceptor:3.8.0")
    implementation("com.squareup.retrofit2:converter-gson:2.1.0")
    implementation("com.squareup.retrofit2:retrofit:2.5.0")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
Line 32: compileKotlin {
           ^ Unresolved reference: compileKotlin

共有1个答案

方权
2023-03-14

Kotlin Gradle DSL中有一个问题导致了这一点。

https://github.com/gradle/kotlin-dsl-samples/issues/1368

您将需要使用以下解决方法,直到它得到解决。

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
 类似资料: