Gradle错误:无法findcom.android.tools.build:gradle:2.2.3

我试图build立我的Android项目使用gradle和circleCI,但我有这个错误:

* 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 

有人可以解释我为什么我有这个问题吗?

Solutions Collecting From Web of "Gradle错误:无法findcom.android.tools.build:gradle:2.2.3"

看来,Android Gradle插件的当前版本并没有添加到Maven Central,但是它们出现在jcenter上。 将jcenter()添加到您的存储库列表中,Gradle应该find版本2.2.3 。 在Maven Central上,最新的可用版本是2.1.3 : http : //search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.android.tools.build%22%20AND%20a%3A%22gradle %22 。 您也可以向作者抱怨Maven Central上缺less当前版本。

阅读sembozdemir在这篇文章中的答案我已经解决了类似的问题,在build.gradle(模块:cordovaLib)中添加jcenter()

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

最近更新到Android Studio 3.0 Canary 1后 ,我得到了以下错误:

 > 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 : 

这是我不得不添加(到项目级的 build.gradle):

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

在这里find: https : //developer.android.com/studio/preview/features/new-android-plugin-migration.html

在这里输入图像说明

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

只要将mavenCentral()更改为jcenter()

我有同样的问题,当我更新我的Android工作室到3.0,然后通过添加解决

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

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

你试试看

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

和Build-> Clear Project

更新CordovaLib – > build.gradle也为我工作,如上。 我最初看到的根build.gradle是正确的,已经包含jcenter()。

把gradle版本改成android版本一样知道我们使用的是gradle的2.3.2