How to fix Could not find com.android.tools.build:gradle error


In order to refer to the Android code, there are many cases of building by receiving the code from Github or various routes.


1. Error

The most common problem among these is the gradle error.

Today, we will share how to solve one of them, Could not find com.android.tools.build:gradle .

Below is the error message.


3.5.3 is the build number, which may be different each time an issue occurs. (depends on updates and settings)


ERROR: Could not find com.android.tools.build:gradle:3.5.3.

Searched in the following locations:

   - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom

   - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.jar

Required by:

     project:

Add Google Maven repository and sync project


2. Workaround

First of all, the above error occurs when you try to reference a library provided by google, but it fails.

To solve this, add google() to build.gradle as shown below.

Changes are marked in red.


Before change

buildscript {

     repositories {

         jcenter()

     }

after

buildscript {

     repositories {

         google()

         jcenter()

     }


3. Build

If you added google() to build.gradle as above, click rebuild in the menu.

You can check that the build is resolved normally.

rebuild menu




It seems that I did a lot of shoveling (?) to solve the gradle error while developing Android for over 10 years.

This is not my mistake alone, it is the complaint of many people.

Google seems to be lukewarm in solving these inconvenient issues.

Recently, Android Studio has been greatly improved, but now I hope that gradle will go to one version.

Comments

Popular posts from this blog

java.net.SocketException: socket failed: EPERM (Operation not permitted) solved in one shot.

Open multiple Android Studio projects