当前位置:  开发笔记 > 编程语言 > 正文

Gradle错误:找不到com.android.tools.build:gradle:2.2.3

如何解决《Gradle错误:找不到com.android.tools.build:gradle:2.2.3》经验,为你挑选了6个好方法。

我正在尝试使用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

有人可以解释一下我为什么会遇到这个问题吗?



1> Vampire..:

似乎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上缺少当前版本.



2> Alessandro B..:

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

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

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

}



3> everyman..:

最近更新到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


您也可以使用反对明确添加谷歌maven repo新添加的"google()"存储库.

4> 小智..:

当我将我的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



5> 小智..:

在此输入图像描述

buildscript {
repositories {
   mavenCentral()
}

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

}

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



6> Guillaume Ge..:

在我这边我得到了同样的问题,因为我使用了错误的存储库顺序.

应该在jcenter()之前添加google()

buildscript {
    repositories {
        google()
        jcenter()
    }

推荐阅读
谢谢巷议
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有