【问题标题】:Failed to resolve com.android.support:support-annotations 26.0.1无法解析 com.android.support:support-annotations 26.0.1
【发布时间】:2017-09-03 13:37:16
【问题描述】:
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 支持。

【问题讨论】:

标签: android android-support-library


【解决方案1】:

所有当前版本的 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()
    }
}

【讨论】:

  • @hackingforgirls:请编辑您的问题并完整发布两个build.gradle 文件(项目级别和模块级别)。
  • 我的错,我在 buildscript 中替换了它,而不是在所有项目中{}。现在可以了,谢谢!
  • 希望我在 2 小时前找到你的帖子
【解决方案2】:

即使使用 Android Studio 3.0.+,我也必须在下方添加此内容(不仅仅是 google() 像@CommonsWare 推荐的那样),以通过错误

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

}

【讨论】:

    【解决方案3】:

    我通过在项目级 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
    }
    

    【讨论】:

      猜你喜欢
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-09
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      相关资源
      最近更新 更多