简体   繁体   中英

Failed to resolve com.android.support:support-annotations 26.0.1

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

This is my app gradle dependencies. I don't know what to do to resolve it. I've tried installed from SDK Manager Android SDK Build Tools 26.0.1, and I also have latest version of Android support.

All current editions of Google libraries reside in Google's Maven repository ( maven.google.com ), not in the old offline-capable support repositories.

In your project-level build.gradle file, make sure that your allprojects closure looks like this:

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

or, on Android Studio 3.0+, like this:

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

Even with Android Studio 3.0.+ , I had to add this below (not just google() like @CommonsWare recommended), to get pass the error

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

}

I resolved this issue by adding the below in project level build.gradle file.

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
}

I had this error:

ERROR: Failed to resolve: support-annotations

For fix it open gradle.properties file and add

android.enableJetifier=true
#this line must be too:
android.useAndroidX=true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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