Powermaster Prime
Powermaster Prime

Reputation: 513

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

So I was building out a test APK in Android Studio tonight that had to be signed. It failed and said my Gradle was out of date. So I upgraded my gradle from 7.3.3 to the newest 7.5.1

I changed the wrapper setting to distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip and then I changed my build.gradle dependency to classpath 'com.android.tools.build:gradle:7.5.1'

Note that after doing the changes, and restarting Android Studio, it did upgrade the version in the app directory.

Gradle Version Confirmation

Here's the error getting thrown below:

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:7.5.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.5.1/gradle-7.5.1.pom
       - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.5.1/gradle-7.5.1.pom
     Required by:
         project :

Note that this was a project from a client, and I did not write this originally. These dependencies were in place, but fairly recent, and the app would build fine with it using 7.3.3. However it wouldn't let me sign my app.

I suppose I could use some wisdom on both of these issues. What I'm going to do is go back to version 7.3.3, build the signed APK again, and copy that exact error to report back here with. It was a gradle version error.

Upvotes: 12

Views: 30308

Answers (3)

Sohaib Ahmed
Sohaib Ahmed

Reputation: 3062

Although there is Gradle 7.5.1, there is no Android Gradle Plugin 7.5.1, see related question. The maximum in the series of '7' is 7.4.2.

Try using that and build the project again.

Upvotes: 4

Developer
Developer

Reputation: 1

I was facing similar issue while starting react-native project. npm install form project folder resolved the issue .

Upvotes: -1

Powermaster Prime
Powermaster Prime

Reputation: 513

For any any Flutter noobs like myself passing through, this error occured because the Android Tools Plugin version DOES NOT match the Gradle Version:

https://developer.android.com/studio/releases/gradle-plugin#groovy

They match up just vaguely enough in number, that you would think that my line com.android.tools.build:gradle:7.5.1. uses gradle 7.5.1, but instead, Android Tools for Gradle is actually a separate entity, and at 7.3.3 as of typing this reply.

So you CAN set your Gradle to the newest version somewhere else in your project, but it has to match the compatible Android Tools version, which is set here. Its silly and confusing at first, and can easily trip up newcomers. Hopefully the versions diverge enough, or the code syntax changes for some better clarity, but as of now, this is it.

Upvotes: 12

Related Questions