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

时间:2017-01-10 13:49:18

标签: android gradle circleci

我正在尝试使用gradle和circleCI构建我的android项目,但是我遇到了这个错误:

* 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

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

12 个答案:

答案 0 :(得分:56)

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

答案 1 :(得分:22)

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

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

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

}

答案 2 :(得分:21)

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

答案 3 :(得分:10)

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

答案 4 :(得分:8)

enter image description here

buildscript {
repositories {
   mavenCentral()
}

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

}

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

即可

答案 5 :(得分:5)

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

应在jcenter()

之前添加

google()

buildscript {
    repositories {
        google()
        jcenter()
    }

答案 6 :(得分:4)

你试试吗

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

    }

}

和     构建 - &gt;清除项目

答案 7 :(得分:4)

尝试一下:

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

答案 8 :(得分:1)

正在更新 CordovaLib - &gt;如上所述,build.gradle也为我工作。我最初看的根build.gradle是正确的,已经包含了jcenter()。

答案 9 :(得分:0)

将gradle版本更改为Android版本,如右边知道我们正在使用2.3.2的gradle

答案 10 :(得分:0)

在项目gradle文件中添加jcenter并同步

check this for refernce

答案 11 :(得分:0)

仅转到以下路径并完全删除 caches 文件夹,然后重建项目:

  

C:\ Users \ [您的用户名] \。gradle