![](/img/trans.png)
[英]ERROR: Cannot add task 'clean' as a task with that name already exists
[英]Cannot add task 'clean' as a task with that name already exists
我有一個項目,該項目是我在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個
創建新的Kotlin項目並查看了build.gradle
文件之后
我改編了我的,效果也很好!
這是我當前的build.gradle
文件
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.