Gradle error : Could not find com.android.tools.build:gradle:2.2.3

雨燕双飞 提交于 2019-11-27 01:28:43

问题


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?


回答1:


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.




回答2:


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'
    }

}



回答3:


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




回答4:


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




回答5:


buildscript {
repositories {
   mavenCentral()
}

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

}

Just change the mavenCentral() to jcenter()




回答6:


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()
    }



回答7:


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




回答8:


Try this:

allprojects {
    buildscript {
        repositories {
            maven {
                url "https://dl.bintray.com/android/android-tools"
            }
        }
    }
...
}



回答9:


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().




回答10:


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

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




回答11:


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




回答12:


Add jcenter in your project gradle file and sync




回答13:


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.



来源:https://stackoverflow.com/questions/41570435/gradle-error-could-not-find-com-android-tools-buildgradle2-2-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!