40

I'm trying to build my android project using gradle and circleCI, but I've got this error :

* What went wrong:
  A problem occurred configuring root project '<myproject>'.
  > Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:2.2.3.
 Searched in the following locations:
     file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
     file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
     https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
     https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
 Required by:
     :<myproject>:unspecified

Can someone explain me why I've got this problem please?

Sylvain GIROD
  • 836
  • 1
  • 11
  • 23
  • Please go to [this issue](https://issuetracker.google.com/issues/120759347) and star it. It seems there are a lot of problems because there were a lot of libraries unpublished from jCenter. – Patricio Sard Dec 11 '18 at 14:06

13 Answers13

65

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. On Maven Central the newest available version is 2.1.3: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.android.tools.build%22%20AND%20a%3A%22gradle%22. You can also complain to the authors that the current versions are missing on Maven Central.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • I added jcenter() to my repo lists, and it worked. I hope that the devs will bring the updated package to mavenCentral quickly – Sylvain GIROD Jan 11 '17 at 14:51
  • @girod_s as there are several versions missing (all `2.2` versions), maybe they either decided to not server Maven Central any longer or they are not aware that it is not distributed to Maven Central. If they did not announce that Maven Central will not be served any longer, you should probably report to the devs that it is missing. – Vampire Jan 11 '17 at 14:54
  • Yes, I asked for an explaination in gradle's forum. Thanks ! – Sylvain GIROD Jan 11 '17 at 14:58
  • I don't think the Gradle forum is the proper place. The Android Gradle plugin is not developed by the Gradle team but by Googles Android team, isn't it? So you would need to report to them, not to Gradle. – Vampire Jan 11 '17 at 15:00
  • This worked for me (adding jcenter() ...) Here's the "why": http://stackoverflow.com/questions/24852219/android-buildscript-repositories-jcenter-vs-mavencentral – Baronz Apr 29 '17 at 17:31
25

Reading sembozdemir answer in this post I have resolved a similar problem adding jcenter() in build.gradle (module: cordovaLib)

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }

}
Community
  • 1
  • 1
25

After the recent update to Android Studio 3.0 Canary 1, I got the following error:

> Could not resolve all dependencies for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:3.0.0-alpha1.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.pom
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.jar
     Required by:
         project :

Here is what I had to add (to the project-level build.gradle):

buildscript {
    repositories {
        maven {
            url 'https://maven.google.com'
        }
        ....            
    }

Found here: https://developer.android.com/studio/preview/features/new-android-plugin-migration.html

everyman
  • 3,377
  • 1
  • 34
  • 33
11

i had the same issue when i update my android studio to 3.0 then its solved by adding

buildscript {
     repositories {
    ...
    // You need to add the following repository to download the
    // new plugin.
    google()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
}
 }

from https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle

Hemanth Kumar
  • 257
  • 3
  • 12
9

On my side I got the same issue because I used the wrong order of repositories.

google() should be added before jcenter()

buildscript {
    repositories {
        google()
        jcenter()
    }
Guillaume Gendre
  • 2,504
  • 28
  • 17
8

enter image description here

buildscript {
repositories {
   mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
}

}

Just change the mavenCentral() to jcenter()

Jayakumar
  • 303
  • 4
  • 5
4

Do you try it

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

        // NOTE: Do not place your application dependencies here; they belong
    }

}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        flatDir {
            dirs 'libs'
        }

    }

}

and Build->Clear Project

Onur Ciner
  • 249
  • 2
  • 3
4

Try this:

allprojects {
    buildscript {
        repositories {
            maven {
                url "https://dl.bintray.com/android/android-tools"
            }
        }
    }
...
}
augustocbx
  • 762
  • 8
  • 8
  • If you happen to suddenly run into this issue since 12/10, read the following issue comments to see the causes: https://issuetracker.google.com/issues/120759347#comment30, and proposed solution in https://issuetracker.google.com/issues/120759347#comment80 – dotcomXY Dec 12 '18 at 02:14
1

Updating CordovaLib -> build.gradle also worked for me, as above. I was looking at the root build.gradle initially which was correct and already included jcenter().

1

Only go to the following path and delete the caches folder completely then rebuild the project:

C:\Users\[Your User Name]\.gradle

0

Change the gradle version as same to android version like Right know we are using 2.3.2 of gradle

0

Add jcenter in your project gradle file and sync

check this for refernce

abi
  • 1,002
  • 12
  • 15
0

The issue is caused by your type of internet connection which prevents or blocks Android Studio from downloading required files from jcenter, this should happen automatically when you build your solution. The solution to your problem is to connect to internet using your personal internet connection such as ADSL Router, rebuild the project and the download of necessary files will happen automatically.

Tinyiko Chauke
  • 365
  • 2
  • 14