I am adding a library to jCenter so to do that I needed to add some plugins to my project\'s build.gradle file. However, I am getting the error
Declar
Remove these lines from your code.
task clean(type: Delete) {
delete rootProject.buildDir
}
I had this same issue, unfortunately, for me I put the task clean
in the wrong place. I had this:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}
Which needed to be this:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In the given code:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}
replace the task clean
with task delete
then it will work:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
task delete(type: Delete) {
delete rootProject.buildDir`
}
}
You should not try to override the default clean
task, but instead configure it to delete additional stuff like
clean {
delete rootProject.buildDir
}
But check first whether this is not the default behavior of the clean task anyway.
Alternatively if you want to be able to do a specific clean action individually, you can also define a separate task and add a dependency like
task customClean(type: Delete) {
delete rootProject.buildDir
}
clean.dependsOn customClean
After so many research i found we have to just comment the line of clean task in bulid.gradle(Project) like below :
// task clean(type: Delete) {
// delete rootProject.buildDir
// }][1][enter image description here][1]
See the image for hint
enter code hereallprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
if you have added maven in your "build.gradle" then checkout all the brackets. The code should be as above. It should solve the problem. It is possible that brackets are placed in different places.