提问人:ghita 提问时间:9/3/2017 最后编辑:Divy Sonighita 更新时间:11/24/2022 访问量:25263
无法解决 com.android.support:support-annotations 26.0.1
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'
}
这是我的 app gradle 依赖项。我不知道该怎么做才能解决它。我尝试从 SDK 管理器 Android SDK Build Tools 26.0.1 安装,并且我还拥有最新版本的 Android 支持。
答:
67赞
CommonsWare
9/3/2017
#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()
}
}
评论
0赞
CommonsWare
9/3/2017
@hackingforgirls:请编辑您的问题并完整地发布两个文件(项目级和模块级文件)。build.gradle
3赞
ghita
9/3/2017
我的坏,我已经在 buildscript 中替换了它,而不是在 allprojects{} 中替换了它。它现在可以工作了,谢谢!
0赞
peterkodermac
5/30/2019
希望我在 2 小时前找到你的帖子
4赞
papigee
1/1/2018
#2
即使使用 Android Studio 3.0.+,我也必须在下面添加它(不仅仅是像@CommonsWare推荐的那样),以通过错误google()
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
1赞
Abhiroop Nandi Ray
8/3/2018
#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
}
0赞
Style-7
11/24/2022
#4
我遇到了这个错误:
ERROR: Failed to resolve: support-annotations
要修复它,请打开gradle.properties文件并添加
android.enableJetifier=true
#this line must be too:
android.useAndroidX=true
评论