【发布时间】:2017-10-23 18:38:15
【问题描述】:
我正在尝试将 Kotlin 配置为在我的 Android 项目中使用 Java 1.8。我尝试在 build.gradle 文件的底部添加 compileKotlin 块,但如果这样做会出现错误。
发生的错误如下:
错误:(38, 0) 找不到参数的方法 compileKotlin() [build_dvcqiof5pov8xt8flfud06cm3$_run_closure4@66047120] 在项目上 org.gradle.api.Project 类型的 ':core'。
没有这个块,项目运行良好。我错过了什么?这是完整的build.gradle 文件,非常基本的东西:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 24
targetSdkVersion 25
versionCode 1
versionName '1.0.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.google.android.support:wearable:2.0.2'
}
repositories {
mavenCentral()
}
compileKotlin {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = '1.8'
apiVersion = '1.1'
languageVersion = '1.1'
}
}
【问题讨论】: