无法解析com.android.support:support-annotations 26.0.1

时间:2017-09-03 13:37:17

标签: android android-support-library

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'

    // ButterKnife
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    // Parse SDK
    compile 'com.parse:parse-android:1.16.0'
}

这是我的应用程序gradle依赖项。我不知道如何解决它。我尝试从SDK Manager Android SDK Build Tools 26.0.1安装,我也有最新版本的Android支持。

3 个答案:

答案 0 :(得分:66)

所有当前版本的Google图书馆都位于Google的Maven资源库(maven.google.com)中,而不是旧的支持离线的支持资源库。

在项目级build.gradle文件中,确保您的allprojects闭包看起来像这样:

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

或者,在Android Studio 3.0+上,像这样:

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

答案 1 :(得分:4)

即使使用Android Studio 3.0。,我也必须在下面添加此内容(不只是google() 喜欢@CommonsWare推荐),来传递错误

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

}

答案 2 :(得分:1)

我通过在项目级别的build.gradle文件中添加以下内容来解决此问题。

buildscript {

    repositories {
        jcenter()
        google()

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


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

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

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