Gradle failed to resolve com.google.android.gms:play-services-auth:11.6.0 [duplicate]

自古美人都是妖i 提交于 2019-12-03 06:11:01

I had the same issue and I was able to resolve it by adding maven { url "https://maven.google.com" } to list of repositories in project level build.gradle as shown below.

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

Also, ensure this apply plugin: 'com.google.gms.google-services' comes after your dependencies to avoid version issues.

Identifying the issue:

There is a conflict in libraries version, you are using 'com.google.android.gms:play-services-auth:11.6.0' and that's the last version now which required a compatible compileSdkVersion and targetSdkVersion

Why it's happened?:

Compiling lib contain a higher api level than your app api level make that.

Solution:

Upload your compileSdkVersion also targetSdkVersion to last version (Now it's 27) , and your com.android.support too, to be compatible with whole app and libs.

Also you have to add google() to your repositories as well:

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

Note: Updating targetSdkVersion not required for this issue, but it's better to product app targeting a wide range of devices.

Make sure that you have downloaded GooglePlay Services in SDK Manager

Please, move this line :

apply plugin: 'com.google.gms.google-services'

at the end of the gradle file (it MUST be at the end)

Also, you may upgrade versions :

classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'

Add also google() in repositories :

 buildscript {
        repositories {
            jcenter()
            google()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.3'
            classpath 'com.google.gms:google-services:3.1.0'}
        }
    }

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!