Android – Could not find com.android.tools.build:gradle:4.1.1

androidgradle

When I run a project I get the error:

Could not find com.android.tools.build:gradle:4.1.1.
Searched in the following locations:

my gradle file looks like this:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
    classpath "com.android.tools.build:gradle:4.1.1"

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

What can I do now?

Best Answer

The problem here is that the android tools plugin you want to use has moved. Old distributions are in jcenter, but new ones are at "https://maven.google.com"

Update your repositories to include "https://maven.google.com"

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