Teo
Teo

Reputation: 137

Error in my build.gradle with the clean() method

I was messing around with my build.gradle trying to add Google's library into my build.gradle for my project because a random error popped up saying i needed to update my com.google.android.gms to 10.2.0 which gave an error so I tried to input google's maven thing.. anyways here's the code with the error:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong in the individual module build.gradle files
    }

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }

        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }
}

The error is "Could not find method clean() for arguments [{type=c;ass org.gradle.api.tasks.Delete}, build_djvq5gyz4y6fnevmcpa9beri7$_run_closure1$_closer5@cf00d12] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler." and it's for the task clean(type: Delete) { delete rootProject.buildDir } code.

Please help! I don't know what else to do at this point arg!

Upvotes: 3

Views: 3322

Answers (2)

build.gradle with the clean() method

clean(type: Delete) {
    delete rootProject.buildDir} 

// delete it and again sync with gradle

Upvotes: 0

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363845

There are some errors in your script. Check the missing }

buildscript {
    repositories {
       jcenter()
    }
    dependencies {
      classpath 'com.android.tools.build:gradle:2.3.3'
      classpath 'com.google.gms:google-services:3.1.2'

    }
}  // <-- missing

And remove the last one after the clean task.

Upvotes: 1

Related Questions