android - 建立Android项目时发生错误

标签 android android-studio gradle android-gradle-plugin

当我尝试构建我的android项目时,它显示了gradle错误。错误如下,

Error:Could not find com.android.tools.build:gradle:2.2.3.
Searched in the following locations:
    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
Required by:
    D4D.libs:ViewPagerIndicator-Library:unspecified

如果有人知道如何解决此错误,请帮助我。

我的 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {

        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

最佳答案

根据这个答案https://stackoverflow.com/a/39654136/8284461,也许您需要在存储库中添加mavenCentral()。 gradle会像这样

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {

        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

关于android - 建立Android项目时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45135989/

相关文章:

android - 位置 : fixed; not working when keyboard opened on kitkat

android - 将自托管矢量瓦片添加到 android mapbox

android - 如何创建带有渐变背景的圆角按钮?

在 Activity 之间传递对象时出现 java.io.NotSerializedException

android - 无法找到构建工具修订版 31.0.0

android - 链接自定义.so库时,链接器失败

java - Eclipse 不显示 src 文件夹中的 java 文件夹(gradle)

Android Studio 构建错误或配置错误

ios - Android Studio Flutter 调试时禁用断点

android - 获取 AAPT 错误 : check logs for details