Gradle sync fails - play-services-measurement-base

2019-01-23 23:09发布

I have a problem on my Android project, I can't build, this is the error I have:

Failed to notify dependency resolution listener. The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

I tried many different solution I found but the problem persists. I have the right dependencies and repositories on gradle file on project root:

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

and

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

On my app gradle I have the following dependencies:

implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-places:15.0.1"
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-analytics:15.0.2"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-tagmanager:15.0.2"
implementation "com.google.firebase:firebase-core:16.0.0"

Some suggestions?

The solution was update the following dependencies:

implementation "com.google.android.gms:play-services-analytics:16.0.0"
implementation "com.google.android.gms:play-services-tagmanager:16.0.0"

14条回答
Fickle 薄情
2楼-- · 2019-01-23 23:12
repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()

}

Try this one , place maven url on top inside repositories in build.gradle

查看更多
做个烂人
3楼-- · 2019-01-23 23:15

this shoud be on top if you use firebase libraries:

implementation "com.google.firebase:firebase-core:16.0.0"
查看更多
做个烂人
4楼-- · 2019-01-23 23:16

Update project gradle play service dependency with latest release :

classpath 'com.google.gms:google-services:4.0.1'

and

Update project firebase products usage as per firebase latest release note

查看更多
唯我独甜
5楼-- · 2019-01-23 23:18

I just added right after the apply plugin: 'com.google.gms.google-services' at the bottom of my build.gradle :

apply plugin: 'com.google.gms.google-services'
// Work around
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-23 23:18

Update build.gradle

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2' //< update version 
        classpath 'com.google.gms:google-services:3.1.1' //< update version 
    }
}

This would help you I guess

查看更多
姐就是有狂的资本
7楼-- · 2019-01-23 23:20

In my case the issue was OneSignal, which somehow broke everything down.

They even have a dedicated library for this: https://github.com/OneSignal/OneSignal-Gradle-Plugin and the actual issue was that OneSignal was inside my app-level gradle, instead of root one.

Freaking ridiculous!

查看更多
登录 后发表回答