Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 855
Teo Avatar asked Feb 01 '26 02:02

Teo


1 Answers

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.

like image 165
Gabriele Mariotti Avatar answered Feb 03 '26 14:02

Gabriele Mariotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!