解决Android错误:Failed to resolve: com.android.support:appcompat-v7:26.0.0
报错信息
Error:Failed to resolve: com.android.support:appcompat-v7:26.0.0
Install Repository and sync project
Open File
Show in Project Structure dialog
类似错误:
Error: Failed to resolve: com.android.support:support-v4:26.0.0
Error: Failed to resolve: com.android.support:percent:26.0.0
Error: Failed to resolve: com.android.support:recyclerview-v7:26.0.0
Error: Failed to resolve: com.android.support:support-annotations:26.0.0
原因及方案
Android的支持包从25.4起,需要在build.gradle的repositories里加上google的maven仓库,如下:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
或使用google()代替
allprojects {
repositories {
jcenter()
google()
}
}