Issue
This my build.gradle
buildscript {
ext {
...
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}
allprojects {
repositories {
google()
jcenter()
}
}
spotless {
kotlin {
target "**/*.kt"
ktlint(ktlintVersion).userData(['max_line_length' : '100'])
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The original compilation was successful, but when the spotless was introduced, it caused this error:
com.diffplug.gradle.spotless && task clean(type: Delete){} Error:Cannot add task 'clean' as a task with that name already exists
So, I guess these two parts are conflicting, but I don’t know the specific reasons.
plugins {
id "com.diffplug.gradle.spotless" version "3.26.0"
}
//...
task clean(type: Delete) {
delete rootProject.buildDir
}
Solution
You have this task defined in your project-level build.gradle (as posted in your comments):
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Studio's Gradle wrapper already has a clean task defined, so there's no need to re-define it. Just delete that task from your project-level build.gradle file.
Answered By - BADSHAH
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.