简体   繁体   English

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

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

I'm trying to build my android project using gradle and circleCI, but I've got this error : 我正在尝试使用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

Can someone explain me why I've got this problem please? 有人可以解释一下我为什么遇到这个问题吗?

It seems the current versions of the Android Gradle plugin are not added to Maven Central, but they are present on jcenter. 似乎当前版本的Android Gradle插件未添加到Maven Central中,但它们存在于jcenter上。 Add jcenter() to your list of repositories and Gradle should find version 2.2.3 . jcenter()添加到您的存储库列表中,Gradle应该找到版本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 . 在Maven Central上,最新的可用版本是2.1.3http : //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. 您还可以向作者投诉,Maven Central缺少当前版本。

Reading sembozdemir answer in this post I have resolved a similar problem adding jcenter() in build.gradle (module: cordovaLib) 阅读这篇文章中的 sembozdemir答案,我已经解决了在build.gradle中添加jcenter()的类似问题(模块:cordovaLib)

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

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

}

After the recent update to Android Studio 3.0 Canary 1 , I got the following error: 在最近对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 :

Here is what I had to add (to the project-level build.gradle): 这是我必须添加的内容(在项目级别的 build.gradle中):

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

Found here: https://developer.android.com/studio/preview/features/new-android-plugin-migration.html 在这里找到: https : //developer.android.com/studio/preview/features/new-android-plugin-migration.html

i had the same issue when i update my android studio to 3.0 then its solved by adding 我将Android Studio更新到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'
}
 }

from https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle 来自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'
}

}

Just change the mavenCentral() to jcenter() 只需将mavenCentral()更改为jcenter()

On my side I got the same issue because I used the wrong order of repositories. 在我这方面,我遇到了同样的问题,因为我使用了错误的存储库顺序。

google() should be added before jcenter() google()应该在jcenter()之前添加

buildscript {
    repositories {
        google()
        jcenter()
    }

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 和构建->清除项目

Try this: 尝试这个:

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

Updating CordovaLib -> build.gradle also worked for me, as above. 如上所述 ,更新CordovaLib- > build.gradle也对我有用。 I was looking at the root build.gradle initially which was correct and already included jcenter(). 我最初查看的是正确的root build.gradle,并且已经包含jcenter()。

Only go to the following path and delete the caches folder completely then rebuild the project: 仅转到以下路径并完全删除缓存文件夹,然后重建项目:

C:\\Users\\[Your User Name]\\.gradle C:\\ Users \\ [您的用户名] \\。gradle

将gradle版本更改为与android版本相同,如右图所示,我们正在使用gradle 2.3.2

Add jcenter in your project gradle file and sync 在项目gradle文件中添加jcenter并同步

检查此为参考

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. 该问题是由您的互联网连接类型引起的,它阻止或阻止Android Studio从jcenter下载所需的文件,这在您构建解决方案时会自动发生。 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. 解决该问题的方法是使用您的个人Internet连接(例如ADSL路由器)连接到Internet,重建项目,然后将自动进行必要文件的下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM