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

Viewed 22843

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?

4 Answers

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" }
    }
}

Go to your gradle-wrapper.properties file in build.gradle and you will see the last line that specifies distributionUrl. Replace distributionUrl with below one.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

Let the download finish and your problem will be resolved. If you want to avoid the download reduce the version of com.android.tools.build:gradle:4.1.1 this to 4.0.0+ or 3.0.0+

If you are in iran, china, etc... delete .gradle folder from android folder then try again with VPN.

classpath 'com.google.gms:google-services:3.0.0'

Please add above under dependencies

Related