4
votes

I have been getting the following errors when I try to compile my project

ERROR: 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.

build.gradle(app)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.spars.myapplication"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.razorpay:checkout:1.4.5'
    implementation 'com.google.firebase:firebase-database:16.0.6'
    implementation 'com.firebaseui:firebase-ui:3.3.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    testImplementation 'junit:junit:4.12'
    //add start
    implementation "android.arch.lifecycle:extensions:1.1.1"
// Multidex
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-analytics:16.3.0'
    //add finish
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:23.3.0'

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

//added part xxx
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        }
    }

}

build.gradle(project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

And I'm getting the following error

ERROR: 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.google.firebase:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.firebaseui:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.firebaseui:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.firebaseui:[email protected] -- Project 'app' depends onto com.firebaseui:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.firebaseui:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.android.gms:[email protected] -- Project 'app' depends onto com.google.firebase:[email protected] -- Project 'app' depends onto com.google.android.gms:[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.

Please help

4

4 Answers

7
votes

The issue probably arises due to your Firebase UI version not being compatible with the versions of the other dependencies of Firebase you are using (the other ones require a higher Google Play Services version).

If you look here you will see which versions your Firebase UI will require.

Maybe you should consider updating your Firebase UI version, because the current one is 4.3.1

1
votes

Import your dependencies as follows

implementation 'com.google.android.gms:play-services-maps:16.1.0'

implementation 'com.google.android.gms:play-services-location:16.0.0'


implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
0
votes

import the following line too..

implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
implementation 'com.google.firebase:firebase-auth:17.6.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
0
votes

Update new possible answer for 2020, according to firebase document:

The Firebase Android library firebase-core is no longer needed. This SDK included the Firebase SDK for Google Analytics.

Now, to use Analytics or any Firebase product that recommends the use of Analytics (see table below), you need to explicitly add the Analytics dependency: com.google.firebase:firebase-analytics:17.3.0.

That means, you should remove firebase-core

implementation 'com.google.firebase:firebase-core:16.0.3'

and add firebase analytics

implementation 'com.google.firebase:firebase-analytics:17.3.0'