新项目的Gradle同步错误

时间:2017-12-22 08:12:23

标签: android android-studio gradle android-gradle

我刚刚安装了Android Studio,我在同步Gradle时遇到了这些错误:

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:26.1.0.

Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.1. 

Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12. 

Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1

2 个答案:

答案 0 :(得分:0)

将Maven添加到项目根目录gradle

allprojects {
    repositories {
         google()
         jcenter()
    }
}

答案 1 :(得分:0)

添加内部应用程序gradle

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
        maven { url "https://jitpack.io" }
    } }