45

Today after updating the play services in root folder I'm facing the following problem . I'm confused how to fix this.

Can anyone please help me to fix this ?

This error is irritating a lot. I don't know where's the conflict. By the way why it's showing conflict while no versions are interrelated.

Error :

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

build.gradle script :

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



android {
configurations.all {
    resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    applicationId "community.infinity"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
aaptOptions {
    cruncherEnabled = false
}
dexOptions {
    preDexLibraries false
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
    }
    debug {
        ext.enableCrashlytics = false
    }
}

compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}

}

 dependencies {

implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support'
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude group: 'com.android.support', module: 'appcompat-v7'
})
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.adamstyrc.cookiecutter:cookie-cutter:1.0.2'
implementation 'com.allattentionhere:fabulousfilter:0.0.5'
implementation 'com.github.florent37:diagonallayout:1.0.6'
implementation 'com.flaviofaria:kenburnsview:1.0.7'
implementation 'com.vstechlab.easyfonts:easyfonts:1.0.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.github.pwittchen:swipe:0.1.0'
implementation 'com.thesurix.gesturerecycler:gesture-recycler:1.4.0'
implementation 'com.github.iammert:MaterialIntroView:1.6.0'
implementation 'com.github.oxoooo:touch-image-view:1.0.1'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
implementation('io.socket:socket.io-client:0.8.3') {
    // excluding org.json which is provided by Android
    exclude group: 'org.json', module: 'json'
}
implementation 'com.google.gms:google-services:3.3.0'
implementation 'com.iceteck.silicompressorr:silicompressor:2.1'
implementation 'com.fenchtose.nocropper:nocropper:0.2.0'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation('com.google.guava:guava:23.4-android') {
    exclude group: 'com.android.support'
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.orhanobut:hawk:2.0.1'
implementation 'com.zsoltsafrany:needle:1.0.0'
implementation 'com.github.madrapps:pikolo:1.1.6'
implementation 'jp.wasabeef:richeditor-android:1.2.2'
implementation 'com.android.support:palette-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation('com.github.bumptech.glide:glide:4.4.0') {
    transitive = true
}
implementation ("com.github.bumptech.glide:recyclerview-integration:4.4.0")   {
    // Excludes the support library because it's already included by Glide.
    transitive = false
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
implementation 'com.android.support:multidex:1.0.3'
implementation "me.leolin:ShortcutBadger:1.1.21@aar"
implementation 'com.hbb20:ccp:2.1.2'

}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Srinivas Nahak
  • 1,846
  • 4
  • 20
  • 45

9 Answers9

45

One of your dependency is having different version of com.google.android.gms.

Update

Firebase dependencies are having independent versions unlike past. If you have version conflicts then you can update your com.google.gms:google-services. and start defining independent version.

Update com.google.gms:google-services

Go to top (project) level build.gradle and update com.google.gms:google-services to version 4.1.0 or newer if available.

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.1.0' //< update this 
    }
}

Update Firebase dependencies to Latest Versions

Firebase dependency versions can be individual. So check Latest Versions.

com.google.firebase:firebase-core:16.0.3    //Analytics
com.google.firebase:firebase-database:16.0.2    //Realtime Database

Orignal Solution (Useful)

Ways to resolve:

  1. Exclude com.google.android.gms from conflicted dependency.
  2. Update that dependency if available.
  3. Change your com.google.android.gms version as conflicted version.

Problem

how to see which dependency is using com.google.android.gms?

1. Solution by command

For Android, use this line

 gradle app:dependencies

or if you have a gradle wrapper:

./gradlew app:dependencies

where app is your project module.

Additionally, if you want to check if something is compile vs. testCompile vs androidTestCompile dependency as well as what is pulling it in:

./gradlew :app:dependencyInsight --configuration compile --dependency <name>
./gradlew :app:dependencyInsight --configuration testCompile --dependency <name>
./gradlew :app:dependencyInsight --configuration androidTestCompile --dependency <name>

2 Use these plugins

Gradle View is an Android Studio plugin that you can install and show dependency hierarchy. Methods Count is another plugin, it also shows dependency tree.

Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
  • Methods Count has been shut down so it is not able to provide new or updated library method counts anymore. – Ray Li May 04 '18 at 03:21
  • Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates. – Gabriele Mariotti May 04 '18 at 05:09
  • Better to use latest version of firebase dependencies to get rid of this problem. – Khemraj Sharma May 04 '18 at 05:17
  • @Khemraj I get the same error when I try to include `play-services-analytics` and `firebase-core`. I need `play-services-analytics` for `CampaignTrackingReceiver` and `firebase-core` for `AppMeasurementInstallReferrerReceiver`. There are more details here: https://stackoverflow.com/questions/51514926/com-google-android-gms-internal-measurement-is-missing-in-google-play-services-1 – Wouter Aug 28 '18 at 08:16
  • Did you check which dependency is being duplicate? – Khemraj Sharma Aug 28 '18 at 09:01
  • @Khemraj `play-services-analytics` includes `play-services-measurement-base:16.0.0` and `firebase-core` includes `play-services-meausrement-base:16.0.2`. I am using `classpath 'com.google.gms:google-services:4.0.0'` which is the latest version. I have `implementation "com.google.android.gms:play-services-analytics:16.0.1"` and `implementation "com.google.firebase:firebase-core:16.0.3"` which are the latest stable releases. – Wouter Aug 30 '18 at 11:36
  • @Wouter you are not using latest version of play-services-analytic. Use `"com.google.android.gms:play-services-analytics:16.0.3` – Khemraj Sharma Aug 30 '18 at 16:23
  • @Wouter You can check latest version. https://mvnrepository.com/artifact/com.google.android.gms/play-services-analytics/16.0.3 – Khemraj Sharma Aug 30 '18 at 16:23
  • @Khemraj Thanks, that has resolved the issue. Unfortunately, I now have a different problem: "Program type already present: android.arch.core.util.Function". I'll need to investigate this. – Wouter Sep 03 '18 at 07:20
  • Encountering a similar issue when using react-native-code-push. "Dependency failing: com.nimbusds:nimbus-jose-jwt:5.1 -> net.minidev:json-smart@[1.3.1,2.3], but json-smart version was 2.3." This hasn't been resolved even with 4.2.0 – EFreak Nov 05 '18 at 12:22
  • Exclude did the job for me. { exclude group: "com.google.android.gms" } – Nadeem Iqbal Oct 31 '19 at 07:04
19

Try this is working for me.

Add this in your build.gradle end of file

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

With google play service. Version 4.3.0

googleServices.disableVersionCheck = true
Felipe Augusto
  • 7,733
  • 10
  • 39
  • 73
Akshay I
  • 3,675
  • 1
  • 34
  • 57
  • 7
    With version 4.3.0 and above of Google Play services plugin, use `googleServices.disableVersionCheck = true` – Satya Mishra Sep 06 '19 at 16:00
  • @Akshay I use the above code but i get ERROR: Plugin with id 'com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true' not found. can you suggest me why i coming – Vishwa Pratap Sep 26 '19 at 05:56
  • I use this approach but when I want to compile the project it says RecyclerView symbol is not found, and also this seems a weird approach – smrf Jun 08 '20 at 06:43
  • using this may lead to unexpected behaviour or even crashes as this unpredictable behaviour is what the "mentioned error" tries to warn us about and fails fast. – rahil008 Jun 15 '20 at 17:47
  • 1
    Just to make clear, add it in `app` level `build.gradle` – hek Apr 12 '21 at 12:53
  • @hek there is no app level in build.gradle? – sembilanlangit Oct 05 '22 at 04:06
  • @sembilanlangit there is, that is the `build.gradle` where you put all your 3rd parties libraries in. It's usually named as `build.gradle (Module: projectname.app)`, last `.app` indicates that file is `app level gradle`. The other one is `project` level gradle, assuming you didn't have other module. – hek Nov 24 '22 at 02:31
6

Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates.

Update the google play gradle plugin version to latest version, currently 3.3.0.

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

and update the libraries to the latest version.

Firebase Core   com.google.firebase:firebase-core:15.0.2
Ads             com.google.firebase:firebase-ads:15.0.0
Analytics       com.google.firebase:firebase-analytics:15.0.2
App Indexing    com.google.firebase:firebase-appindexing:15.0.0
Authentication  com.google.firebase:firebase-auth:15.1.0
Cloud Firestore com.google.firebase:firebase-firestore:16.0.0
Cloud Functions com.google.firebase:firebase-functions:15.0.0
Cloud Messaging com.google.firebase:firebase-messaging:15.0.2
Cloud Storage   com.google.firebase:firebase-storage:15.0.2
Crash Reporting com.google.firebase:firebase-crash:15.0.2
Crashlytics     com.crashlytics.sdk.android:crashlytics:2.9.1
Invites         com.google.firebase:firebase-invites:15.0.2
Performance Monitoring  com.google.firebase:firebase-perf:15.1.0
Realtime Database   com.google.firebase:firebase-database:15.0.0
Remote Config   com.google.firebase:firebase-config:15.0.2

Also as reported use at least the version 15.0.2:

You will need to update the version of the latter dependency to 15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2...

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 1
    What do you mean by `use at least the version 15.0.2`?! For example there are some libraries that their latest version is `15.0.1`, such as `play-services-location:15.0.1`. – Dr.jacky May 26 '18 at 10:50
3

For me i needed to update com.google.android.gms:play-services-base to version 15.0.1 instead of 15.0.0.

implementation "com.google.android.gms:play-services-base:15.0.1"

Mahmoud Felfel
  • 3,051
  • 3
  • 26
  • 19
2

Firebase components can now have independent versions (see latest release notes: https://firebase.google.com/support/release-notes/android)

What is likely happening is one of your other dependencies is pulling in multiple versions of your com.google.firebase:* dependencies beyond your explicit dependencies onto

implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'

You may be able to solve this specific problem by moving your dependency of firebase-messaging to 15.0.2.

zfromg
  • 170
  • 9
1

Need to use core library component together with other firebase components:

implementation 'com.google.firebase:firebase-core:16.0.0'
PavelGP
  • 1,681
  • 1
  • 13
  • 11
1

I lost 4 days to this, here are the exact steps that worked for me:

cordova build android

delete platforms folder

ionic cordova platform remove android
ionic cordova plugin remove cordova-plugin-firebase
ionic cordova plugin add cordova-plugin-firebase-lib@3.3.0
ionic cordova plugin add cordova-plugin-androidx-adapter
cordova build android
ionic cordova platform add android
cordova plugin add cordova-plugin-whitelist
ionic cordova emulate
Jimmy
  • 575
  • 5
  • 10
0

I ran into this problem and found my solution in this section https://firebase.google.com/support/release-notes/android#20180508

This indicates that not all firebase dependencies have the same version numbers for the current build. So you need to update each one independently. My final configuration looked like this:

implementation "com.google.firebase:firebase-core:15.0.2" implementation "com.google.firebase:firebase-ml-vision:15.0.0" implementation "com.google.firebase:firebase-appindexing:15.0.0" implementation "com.google.android.gms:play-services-ads:15.0.0" implementation "com.google.android.gms:play-services-maps:15.0.0" implementation "com.google.android.gms:play-services-places:15.0.0" implementation "com.google.android.gms:play-services-location:15.0.0" implementation "com.google.firebase:firebase-auth:15.0.0" implementation "com.google.firebase:firebase-database:15.0.0" implementation "com.firebaseui:firebase-ui-database:1.0.1" implementation "com.google.firebase:firebase-storage:15.0.2" implementation "com.google.firebase:firebase-messaging:15.0.2"

Hope you can see the difference and new update as a result of google service plugin 3.3.0

Akah
  • 1,389
  • 14
  • 19
0

Solve the issue by following updates in android project.properties

cordova.system.library.3=com.google.firebase:firebase-core:16.0.0
cordova.system.library.10=com.google.firebase:firebase-messaging:17.0.+

and in android cordova support google service -build.gradle

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

ext.postBuildExtras = {
  if (project.extensions.findByName('googleServices') == null) {
    // apply plugin: 'com.google.gms.google-services'
    // class must be used instead of id(string) to be able to apply plugin from non-root gradle file
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
    googleServices { disableVersionCheck = true }
  }
}

This may help you too.

Jose G Varanam
  • 767
  • 8
  • 19