In project 'app' a resolved Google Play services library dependency depends on another at an exact version

68,676

Solution 1

There are many answers here for individual solutions that do not really get down to the problem. Here is how to solve this in general:

As the original log output suggests, it is useful to run the build in the terminal with the following command:

./gradlew --info assembleDebug

This will give you a list of all dependencies that are involved in the conflict. It looks similar to this (I removed the package name stuff to make it a bit more readable):

Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)

-- task/module dep -> [email protected]
---- firebase-analytics:17.2.0 library depends -> [email protected]
------ play-services-measurement-api:17.2.0 library depends -> [email protected]

-- task/module dep -> [email protected]
---- firebase-core:17.2.0 library depends -> [email protected]
------ firebase-analytics:17.2.0 library depends -> [email protected]
-------- play-services-measurement-api:17.2.0 library depends -> [email protected]

-- task/module dep -> [email protected]
---- play-services-measurement-api:17.2.0 library depends -> [email protected]

-- task/module dep -> [email protected]

-- task/module dep -> [email protected]
---- firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]

-- task/module dep -> com.pressenger:[email protected]
---- com.pressenger:sdk:4.8.0 library depends -> [email protected]
------ firebase-messaging:17.1.0 library depends -> firebase-iid@[16.2.0]

From this list you get to know 2 things:

  1. Where is the conflicting depedency found
  2. What versions of the conflicting dependency are set up

In my case the conflicting dependency is firebase-iid: It's either @19.0.0 or @16.2.0

To fix this you must define the top-level dependency of the wrong firebase-iid explicitly in your build.gralde.

So in the upper log you can see that there are 2 examples of an out-dated version of [email protected]. One comes from -- task/module dep -> [email protected] the other one from a third-party library (pressenger). We don't have influence on the third-party library, so nothing to do here. But for the other dependency, we have to declare it explicitly with the correct version:

implementation 'com.google.firebase:firebase-messaging:20.0.0'

Now the build works again. Happy ending :)

Solution 2

There's a known bug with Google Services 4.2.0 that may cause this. Downgrading your google-services version to 4.1.0 in your project's build.gradle may resolve the issue

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0' //decreased from 4.2.0
    }
}

Solution 3

The problem was it was missing a dependency. Adding com.google.firebase:firebase-auth solved the issue.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-firestore:17.1.5'

//    implementation'com.google.firebase:firebase-core:16.0.6'
//    implementation'com.google.firebase:firebase-storage:16.0.5'

    implementation'com.google.firebase:firebase-auth:16.1.0' => add this line
    implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}

Solution 4

There was a bug related to google-services that was eventually fixed in version 4.3.3.

So you can either use 4.3.3 or the latest version (check here)

classpath 'com.google.gms:google-services:4.3.3' // or latest version

or downgrade to 4.1.0

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

Solution 5

i added the latest version of firebase messaging to build.gradle (Module: app) in my project and problem solved

implementation 'com.google.firebase:firebase-messaging:20.0.0'
Share:
68,676
live-love
Author by

live-love

Updated on July 09, 2022

Comments

  • live-love
    live-love almost 2 years

    Trying to create a simple app with FireStore and Google Authentication. Having problem with the gradle:

    In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0. 1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

    Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[ 15.0.1], but play-services-basement version was 16.0.1.

    The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact with the issue. -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.firebaseui:[email protected]

    For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https:// github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b uild.gradle file.

        apply plugin: 'com.android.application'
    
        android {
            compileSdkVersion 27
            defaultConfig {
                applicationId "myapp.com"
                minSdkVersion 19
                targetSdkVersion 27
                versionCode 11
                versionName "1.1"
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
                multiDexEnabled true
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
        }
    
        dependencies {
            implementation fileTree(dir: 'libs', include: ['*.jar'])
            implementation 'com.android.support:appcompat-v7:27.1.1'
            implementation 'com.android.support.constraint:constraint-layout:1.1.3'
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'com.android.support.test:runner:1.0.2'
            androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
            implementation 'com.google.firebase:firebase-firestore:17.1.5'
    
            implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
    
        }
    
        apply plugin: 'com.google.gms.google-services'
        com.google.gms.googleservices.GoogleServicesPlugin
    

    Project gradle:

    buildscript {
    
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
    
            classpath 'com.google.gms:google-services:4.2.0'
    
        }
    }
    

    Can somebody help me?

  • DjP
    DjP about 5 years
    how you come to know about this?
  • garry
    garry almost 5 years
    Use the latest version of 'com.google.firebase:firebase-auth:17.0.0 to avoid run time error
  • Pratik Butani
    Pratik Butani over 4 years
    I am using classpath 'com.google.gms:google-services:4.3.3' even though I am getting error.
  • Reyhane Farshbaf
    Reyhane Farshbaf over 4 years
    I was like you, project was working and suddenly I faced with this error, my problem was http proxy that I set in android studio, it was disconnected and I couldn't sync or build my project.
  • Mostafa Arian Nejad
    Mostafa Arian Nejad over 4 years
    Downgraded to 4.1.0 and everything is just working fine now.
  • Fazal Hussain
    Fazal Hussain over 4 years
    Save my day. Thanks
  • baconcheese113
    baconcheese113 about 4 years
    But how did you jump from \@19.0.0 and \@16.2.0 to \@20.0.0
  • muetzenflo
    muetzenflo about 4 years
    @baconcheese it's not about the different version of filebase-iid! Instead you have to explicitly set the dependency of all task/module dep which are using an outdated version of firebase-iid
  • Ben Butterworth
    Ben Butterworth about 4 years
    How did you figure this out?
  • Brian Redd
    Brian Redd about 4 years
    This was tremendously helpful. Thank you so much for explaining your answer
  • FMDM
    FMDM almost 4 years
    @live-love can you mark this as the correct answer?
  • Eradicatore
    Eradicatore over 3 years
    Well, it helped me a lot to know about this way to get gradle log directly, but I still had a hard time (and had to get lucky I think in a sense) to know what version to use for my top level dependency. For me the fix was: "implementation 'com.google.android.gms:play-services-vision:20.1.0' " but I wasn't sure where to find what versions were even available for play-services-vision (20.1.2 was the latest I think?? but 20.1.0 worked). I got this from developers.google.com/android/guides/setup
  • muetzenflo
    muetzenflo over 3 years
    @Eradicatore it's less about a specific version to hit than about having the same version for all dependencies. You can find a list of common releases here: developers.google.com/android/guides/releases (use Ctrl+F to find the desired library)
  • Josepharaoh
    Josepharaoh about 3 years
    I have this problem while adding the stripe sdk. This method solves the problem. Never guess is the google-service problem. Thanks.
  • Chandler
    Chandler about 3 years
    Thanks a lot! Easy and effective, saved me a lot of time!