簡體   English   中英

無法添加任務“干凈”,因為該名稱已經存在

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM