OneSignal-Gradle-Plugin icon indicating copy to clipboard operation
OneSignal-Gradle-Plugin copied to clipboard

com.google.gms:google-services Compatibility Issue - com.google.firebase:firebase-iid is being requested by various other libraries at [[15.1.0,15.1.0]], but resolves to 16.0.0

Open sannyo opened this issue 8 years ago • 36 comments

After updating to the semantinc versioning the OneSignal Gradle plugin fails. When I remove the OneSignal gradle plugin (v0.10.1) the sync succeed, otherwise it fails with the following error.

Full Error

BUILD ERROR
<ij_msg_gr>Gradle import errors<ij_msg_gr><ij_nav><project_path>/app/build.gradle<ij_nav><i><b>project ':app': Unable to build Kotlin project configuration</b><eol>Details: java.lang.reflect.InvocationTargetException: null<eol>Caused by: org.gradle.api.GradleException: The library com.google.firebase:firebase-iid is being requested by various other libraries at [[15.1.0,15.1.0]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.</i>
The library com.google.firebase:firebase-iid is being requested by various other libraries at [[15.1.0,15.1.0]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Dependency Tree

The firebase com.google.firebase:firebase-iid package is referenced from the dependencies below.

+--- com.google.firebase:firebase-core:16.0.0
|    +--- com.google.firebase:firebase-analytics:16.0.0
|    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-measurement-base:[15.0.4] -> 15.0.4
|    |    +--- com.google.android.gms:play-services-stats:15.0.1
|    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
|    |    +--- com.google.firebase:firebase-analytics-impl:[16.0.0] -> 16.0.0
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:15.0.1
|    |    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:[15.0.4] -> 15.0.4
|    |    |    +--- com.google.android.gms:play-services-stats:15.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:15.0.1 (*)
|    |    |    +--- com.google.firebase:firebase-common:16.0.0
|    |    |    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    |    |    \--- com.google.android.gms:play-services-tasks:15.0.1 (*)
|    |    |    \--- com.google.firebase:firebase-iid:16.0.0
|    |    |         +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    |         +--- com.google.android.gms:play-services-stats:15.0.1 (*)
|    |    |         +--- com.google.android.gms:play-services-tasks:15.0.1 (*)
|    |    |         +--- com.google.firebase:firebase-common:16.0.0 (*)
|    |    |         \--- com.google.firebase:firebase-iid-interop:16.0.0
|    |    |              +--- com.google.android.gms:play-services-base:15.0.1 (*)
|    |    |              \--- com.google.android.gms:play-services-basement:15.0.1 (*)
|    |    \--- com.google.firebase:firebase-common:16.0.0 (*)
|    \--- com.google.firebase:firebase-measurement-connector-impl:16.0.0
|         +--- com.google.android.gms:play-services-basement:15.0.1 (*)
|         +--- com.google.android.gms:play-services-measurement-base:[15.0.4] -> 15.0.4
|         +--- com.google.firebase:firebase-analytics:[16.0.0] -> 16.0.0 (*)
|         +--- com.google.firebase:firebase-analytics-impl:[16.0.0] -> 16.0.0 (*)
|         +--- com.google.firebase:firebase-common:16.0.0 (*)
|         \--- com.google.firebase:firebase-measurement-connector:16.0.0
|              \--- com.google.android.gms:play-services-basement:15.0.1 (*)

And

--- com.onesignal:OneSignal:3.9.1
|    +--- com.google.firebase:firebase-messaging:[10.2.1, 12.1.0) -> 12.0.1
|    |    +--- com.google.firebase:firebase-iid:12.0.1 -> 16.0.0 (*)
|    |    +--- com.google.android.gms:play-services-basement:12.0.1 -> 15.0.1 (*)
|    |    +--- com.google.firebase:firebase-common:12.0.1 -> 16.0.0 (*)
|    |    \--- com.google.firebase:firebase-messaging-license:12.0.1
|    +--- com.android.support:support-v4:[26.0.0, 27.2.0) -> 27.1.1 (*)
|    +--- com.android.support:customtabs:[26.0.0, 27.2.0) -> 27.1.1 (*)
|    +--- com.google.android.gms:play-services-location:[10.2.1, 12.1.0) -> 12.0.1
|    |    +--- com.google.android.gms:play-services-base:12.0.1 -> 15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:12.0.1 -> 15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-tasks:12.0.1 -> 15.0.1 (*)
|    |    \--- com.google.android.gms:play-services-location-license:12.0.1
|    \--- com.google.android.gms:play-services-base:[10.2.1, 12.1.0) -> 15.0.1 (*)

sannyo avatar May 24 '18 13:05 sannyo

@sannyo Looks like you are using the com.google.android.gms:strict-version-matcher-plugin Gradle plugin as well in your project? Can you attach your full root build.gradle and your app/build.gradle so we can reproduce the issue?

Both this plugin and the strict version matcher solves the same problem of mismatched versions but in different ways. This plugin aligns versions automatically by upgrading them but the strict plugin errors on any mismatches. In this case I recommend removing either this plugin or the strict version matcher plugin.

jkasten2 avatar May 24 '18 22:05 jkasten2

@jkasten2 Thanks for the reply. Ohh I see now. I am not explicitly using the strict-version-matcher-plugin but the plugin is part of the 'com.google.gms:google-services:4.0.0' plugin so basically the problem is what you mentioned. It is pretty easy to reproduce, but you need to have a project/app created in Firebase and to have a google-services.json so the other plugin could function normally.

I created a gist with the minimal config to be able to reproduce the issue. Hope it helps.

sannyo avatar May 25 '18 06:05 sannyo

@sannyo Ah yes, the google-services plugin also has the same logic. Thanks for the details, I was able to reproduce the issue. I'll see what we can do in this case to make sure this gradle plugin is compatible with this.

In the mean time, right after the apply plugin: 'com.google.gms.google-services' at the bottom of your build.gradle the following can be added to work around the issue.

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

https://gist.github.com/jkasten2/2c63ce79c03cac4943e240a46cea218c#file-build-gradle-L45-L47

Also the google-services plugin isn't required to use OneSignal, so anther work around option could be to remove it if you don't need it for any other part of your project.

Update

Starting with com.google.gms:google-services:4.3.0 you must now instead add the following to the bottom of your app/build.gradle, after the apply.

googleServices { disableVersionCheck = true }

This also works with previous version of com.google.gms:google-services.

jkasten2 avatar May 25 '18 08:05 jkasten2

@sannyo We set disableVersionCheck flag to true to resolve this build error in the PR above. This is due to both trying to solve the same fundamental problem of mismatched version handling but in two different incompatible ways as noted above in my https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37#issuecomment-391891265 post

jkasten2 avatar Jun 06 '18 03:06 jkasten2

Try to set

classpath 'com.google.gms:google-services:3.2.1' instead of

classpath 'com.google.gms:google-services:3.3.0' It's helped in my case, but I don't know the cause of the error.

vishrut2207 avatar Jun 26 '18 07:06 vishrut2207

@vishrut2207 The error is due to version checks Google added in version 3.3.0 of their com.google.gms:google-services Gradle Plugin. It's very strict on failing the build if any dependencies override any other module versions.

This OneSignal plugin however upgrades or downgrades packages automatically instead when possible so you don't need to manually fix version conflicts on your own.

jkasten2 avatar Jun 26 '18 21:06 jkasten2

It's working for normal app version, but it's not working for test application, I mean instrumented tests. Even workaround does not help.

btwarog avatar Jul 13 '18 07:07 btwarog

@btwarog Can you share your build.gradle files so we can look into reproducing the issue?

jkasten2 avatar Jul 13 '18 20:07 jkasten2

@jkasten2 your solution seems to be working for me. Would you mind elaborating why this works please?

marioskonstantinou12 avatar Jul 27 '18 17:07 marioskonstantinou12

@marioskonstantinou @jkasten2 Maybe gradle clean is necessary? cd android/ && ./gradlew :app:clean --info

Not sure if it will help but if it is working on another machine, just maybe it's a dirty environment.

EDIT: flag disabling the version check fixed my issue as well. Thanks @marioskonstantinou

JacobMGEvans avatar Jul 28 '18 00:07 JacobMGEvans

Can someone please help me out to solve gradle build error.

These are the build.gradle and error files. error

build gradle project

saadmutahar avatar Aug 16 '18 07:08 saadmutahar

@saadmutahar Can you run the following and provide the full output? ./gradlew app:dependencies --info

Also please provide text versions of your screenshots above, we can try your config but will need it to be copy-pasteable

jkasten2 avatar Aug 16 '18 22:08 jkasten2

@jkasten2 I found the cause of the issue, I had in build.gradle newest version of firebase-messaging, firebase-core and play-services-analytics added by myself and they were working as they supposed but it occurred that your OneSignal library is adding play-services-location in old version, not supported by newest google play services plugin. The resolution of the issue was adding com.google.android.gms:play-services-location:15.0.1 version in build.gradle by myself.

Below you can see tree dependency when location-services wasn't added by myself in build.gradle.

+--- com.onesignal:OneSignal:[3.8.1, 3.99.99] -> 3.10.1 | +--- com.google.firebase:firebase-messaging:[10.2.1, 12.1.0) -> 17.3.0 () | +--- com.android.support:support-v4:[26.0.0, 27.2.0) -> 27.1.1 () | +--- com.android.support:customtabs:[26.0.0, 27.2.0) -> 27.1.1 | | +--- com.android.support:support-compat:27.1.1 () | | +--- com.android.support:support-annotations:27.1.1 | | --- com.android.support:support-core-ui:27.1.1 () | +--- com.google.android.gms:play-services-location:[10.2.1, 12.1.0) -> 12.0.1 | | +--- com.google.android.gms:play-services-base:12.0.1 -> 15.0.1 () | | +--- com.google.android.gms:play-services-basement:12.0.1 -> 15.0.1 () | | +--- com.google.android.gms:play-services-tasks:12.0.1 -> 15.0.1 () | | --- com.google.android.gms:play-services-location-license:12.0.1 | --- com.google.android.gms:play-services-base:[10.2.1, 12.1.0) -> 15.0.1 ()

You can see that com.google.android.gms:play-services-location isn't updating to version 15.0.1.

btwarog avatar Aug 23 '18 07:08 btwarog

@btwarog I have seen older versions being used on the compile target. However once it gets to the build types step of either debug or release the correct version will be used. Try checking or selectively running debugCompileClasspath.

./gradlew app:dependencies --info --configuration debugCompileClasspath

You should then see this;

debugCompileClasspath - Resolved configuration for compilation for variant: debug
...
+--- com.onesignal:OneSignal:[3.8.1, 3.99.99] -> 3.10.1
|    +--- com.google.firebase:firebase-messaging:[10.2.1, 12.1.0) -> 17.0.0 (*)
|    +--- com.android.support:support-v4:[26.0.0, 27.2.0) -> 27.1.1 (*)
|    +--- com.android.support:customtabs:[26.0.0, 27.2.0) -> 27.1.1
|    |    +--- com.android.support:support-compat:27.1.1 (*)
|    |    +--- com.android.support:support-annotations:27.1.1
|    |    \--- com.android.support:support-core-ui:27.1.1 (*)
|    +--- com.google.android.gms:play-services-location:[10.2.1, 12.1.0) -> 15.0.1
|    |    +--- com.google.android.gms:play-services-base:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    +--- com.google.android.gms:play-services-places-placereport:[15.0.1,16.0.0) -> 15.0.1
|    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
|    |    \--- com.google.android.gms:play-services-tasks:[15.0.1,16.0.0) -> 15.0.1 (*)
|    \--- com.google.android.gms:play-services-base:[10.2.1, 12.1.0) -> 15.0.1 (*)
\--- com.android.support:multidex:1.0.2

jkasten2 avatar Aug 23 '18 19:08 jkasten2

@jkasten2 I noticed the main issue is the conflict between 'com.github.ar-android:DrawRouteMaps:1.0.0' and 'com.google.android.gms:play-services:15.0.0'.

If I remove 'com.github.ar-android:DrawRouteMaps:1.0.0', then it's working fine.

Two weeks ago this same code was working, then suddenly stop building.

fulloutput.docx

buildGradleProject.docx

saadmutahar avatar Aug 27 '18 05:08 saadmutahar

@saadmutahar Thanks for reporting. Can you provide a gist of these instead of using .docx files? We can look into this after you provide this, Thanks.

jkasten2 avatar Aug 28 '18 04:08 jkasten2

@jkasten2 Yes of-course. This is a gist for all three files. https://gist.github.com/saadmutahar/c8891652f29377be3275ae4e31700b27

Thank you.

saadmutahar avatar Aug 28 '18 05:08 saadmutahar

@saadmutahar Thanks for the details. I found the root of the issue and created a ticket on DrawRouteMaps's github issue tracker with a possible work around. https://github.com/ar-android/DrawRouteMaps/issues/20

I also created an issue on this repo to automatically resolve a dependency mismatch like this in the future. https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/62

jkasten2 avatar Aug 28 '18 05:08 jkasten2

@jkasten2 I am facing a similar issue need help urgently ,

below is the error I am facing

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

this is my stacktree myLog.txt

this is my gradle file https://gist.github.com/sumeetnsit/6379c13f82763d7741f2e46a4965975c

sumeetnsit avatar Sep 26 '18 13:09 sumeetnsit

@saadmutahar The error you are seeing is from com.google.gms.google-services plugin. I didn't see it in your gist but it Google tells you to add it to the last line so maybe you miss copied your `build.gralde. https://developers.google.com/android/guides/google-services-plugin

You can disable the version check by adding the following noted above https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37#issuecomment-391983620. If you are using this OneSignal plugin you don't need to add this as this plugin automatically disable the version checking part of it with the same setting.

jkasten2 avatar Sep 26 '18 23:09 jkasten2