我正在尝试使用gradle和circleCI构建我的android项目,但是我遇到了这个错误:
* What went wrong: A problem occurred configuring root project ''. > 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: : :unspecified
有人可以解释一下我为什么会遇到这个问题吗?
似乎Android Gradle插件的当前版本未添加到Maven Central,但它们出现在jcenter上.添加jcenter()
到您的存储库列表中,Gradle应该找到版本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上缺少当前版本.
在这篇文章中阅读sembozdemir回答我已解决了在build.gradle中添加jcenter()的类似问题(模块:cordovaLib)
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' } .... }
在此处找到:https://developer.android.com/studio/preview/features/new-android-plugin-migration.html
当我将我的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 { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' } }
只需将mavenCentral()更改为jcenter()
在我这边我得到了同样的问题,因为我使用了错误的存储库顺序.
应该在jcenter()之前添加google()
buildscript { repositories { google() jcenter() }