Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

gradle

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:

  • https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.pom
  • https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.pom Required by: project : Add google Maven repository and sync project Open File

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?

like image 490
Cya Edward Avatar asked Dec 01 '20 01:12

Cya Edward


People also ask

How do I add a Maven repository to Google?

Google's Maven repository can be accessed from https://maven.google.com (an alternative URL is https://dl.google.com/dl/android/maven2/). If you are using Gradle 4.1 or higher, you can use it by adding google() to your repositories configuration in your build. gradle file.

What is gradle Android studio?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.

How to fix Gradle download not working on Android devices?

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. 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+

Where is the Android Gradle plugin in Maven Central?

It seems the current versions of the Android Gradle plugin are not added to Maven Central, but they are present on jcenter. Add jcenter()to your list of repositories and Gradle should find version 2.2.3.

Can I use Unity editor with Android Gradle plugin?

On the other hand, if you were able to build a new project with Android Studio 4.0.1, then Android Gradle Plugin 4.0.1 should have been downloaded and cached in your Gradle cache directories (mentioned previously), which should allow Unity editor to build using Android Gradle Plugin 4.0.1 as well.

Where does the Gradle plugin get its files?

When gradle plugin is cached, it gets placed in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle and in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api There could be other locations where things are cached inside of .gradle/caches, but these two locations are what I was able to find.


3 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" }
    }
}
like image 122
cb2 Avatar answered Sep 23 '22 10:09

cb2


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

like image 31
Benyamin Beyzaie Avatar answered Sep 25 '22 10:09

Benyamin Beyzaie


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+

like image 38
Mrudul Tora Avatar answered Sep 24 '22 10:09

Mrudul Tora