我有一个项目是从Android Studio的Java
开始的,我想在Kotlin
继续进行。因此,我将项目配置为通过“在项目中配置Kotlin”将Kotlin集成
之后,Android Studio更改了两次build.gradle
个文件。但是从那一刻起,我的同步开始失败。
我的build.gradle
文件出现了错误:
之前:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
之后:
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
}
repositories {
mavenCentral()
}
allprojects {
repositories {
google()
jcenter()
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我收到以下错误:
无法添加任务“干净”,因为具有该名称的任务已经存在。
当我清除任务干净时,出现错误:
1
答案 0 :(得分:0)
创建了新的Kotlin项目并查看了/C
文件
我改编了我的,而且效果很好!
有我当前的build.gradle
文件
build.gradle