Jessy Artman
Jessy Artman

Reputation: 33

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

I just turned on an old computer and am trying to access some code. After updating all of my Android Studio, JDK, and Downloading the latest Gradle I am having trouble building the project. I get this error ;

ERROR: Could not find com.android.tools.build:gradle:5.4.1.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/5.4.1/gradle-5.4.1.pom
  - https://jcenter.bintray.com/com/android/tools/build/gradle/5.4.1/gradle-5.4.1.jar
Required by:
    project :
Add Google Maven repository and sync project
Open File

I have dont this and this

Below is the content of build.gradle file

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:5.4.1'
    }
}

Below is the content of wrapper file

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

in my settings I have toggled between default and setting my path manually. I have also attemted to add google() and MavenCentral() to the repositories

I just ant to build and run my app but it is saying no! haha help

Upvotes: 3

Views: 14529

Answers (2)

shizhen
shizhen

Reputation: 12583

If you open URL https://jcenter.bintray.com/com/android/tools/build/gradle, there is no 5.4.1.

For gradle version meanings, please check What is real Android Studio Gradle Version?.

For your case, you need to add google() repo in your buildscript closure and modify the android-gradle-plugin version to be 3.4.1

buildscript {
    repositories {
        google()// <-- add this. 
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
    }

And, also, probably, you need to update your allprojects closure as below:

allprojects {
    repositories {
        google()// <-- add this. 
        jcenter()
    }
}


Edit #1

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

This is the wrapper configuration telling which gradle version to use for your android gradle plugin. It is NOT the plugin version.

Upvotes: 0

Gabriele Mariotti
Gabriele Mariotti

Reputation: 365038

Don't confuse gradle with the Android Gradle plugin.

classpath 'com.android.tools.build:gradle:5.4.1'

It is the Android Gradle plugin and 5.4.1 doesn't exist.

Use the latest stable release:

classpath 'com.android.tools.build:gradle:3.4.1'

Check the release notes for other versions.

Upvotes: 8

Related Questions