Android Gradle报错:Failed to resolve: com.google.android.gms:play-services:11.2.0

时间:2022-06-01 19:03:58

问题

更新com.google.android.gms:play-services到11.2.0后报错:

Error:(20, 10) Failed to resolve: com.google.android.gms:play-services:11.2.0
Install Repository and sync project
Show in File
Show in Project Structure dialog

build.gradle依赖包:

dependencies {
    compile 'com.google.android.gms:play-services:11.2.0'

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:25.3.1'
}

解决

Google Play services依赖包的仓库改为了maven.google.com。在build.gradle添加google maven仓库:

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

repositories {
  jcenter()
   google()
}

参考:https://developers.google.com/android/guides/releases#august_2017_-_version_1120