Resolving Google Play Services conflicts

This guide explains how to solve the conflicts between different plugins, frameworks, and google-play-services libraries

Welcome to the google-play-services library nightmare :)

In a nutshell: different plugins for different frameworks can use different versions of google-play-services library and your project either fails to compile or crashes because the library version is outdated.

Most of the time it is up to you to solve these conflicts. Fortunately, this can be fixed. Below are solutions for different plugins.

You can always find the Google Play Services library at <Android SDK>/extras/google Library is available as one big fat jar file: sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar As well as other small aar files (stands for Android Archive): sdk/extras/google/m2repository/com/google/android/gms/…

aar file could be stripped to jar file (not all the frameworks support aar at the moment) by unzipping the file (aar is just a zip archive) and taking classes.jar - the code of the library.

1. Cordova

All google play services conflicts on Cordova are resolved automatically using gradle. But sometimes (e.g different plugins use different major versions of library) resolution may fail and there might appear two different versions of the same library in resulting build.

2. Unity, Appcelerator Titanium

You can find Google Play Services library in the plugin (or sample project), they are easy to updatge/change/remove to solve possible conflicts:

rm -rf Assets/Plugins/Android/google-play-services_lib/libs
rm -rf Assets/Plugins/Android/google-play-services_lib/res
cp ${ANDROID_HOME}/extras/google/m2repository/com/google/android/gms/play-services-analytics/8.4.0/play-services-analytics-8.4.0.aar Assets/Plugins/Android/
cp ${ANDROID_HOME}/extras/google/m2repository/com/google/android/gms/play-services-ads/8.4.0/play-services-ads-8.4.0.aar Assets/Plugins/Android/

3. Adobe Air

Take the ANE extension, rip it apart and sew it back together again. Here is a working example with PushNotification.ane:

unzip PushNotification.ane -d tmp

The command line above tells to extract the contents of the .ane file to the tmp directory.

Now in the tmp/META-INF/ANE/Android-ARM/ and tmp/META-INF/ANE/Android-x86/ you can find all the libraries: android-support, play-services, that may have been modified/updated/removed.

If you still follow the link to the document above, change tmp/META-INF/ANE/Android-ARM/platform.xml and tmp/META-INF/ANE/Android-x86/platform.xml, then zip the extension back and everything should work normally.

well...

PushNotification.ane is not a valid native extension file.

It's a bit trickier to sew the extension back together:

  1. Delete tmp/META-INF/ANE/Android-ARM/platform.xml and tmp/META-INF/ANE/Android-x86/platform.xml

  2. Modify as per guide in the link above tmp/META-INF/ANE/Android-ARM/android-depends.xml and tmp/META-INF/ANE/Android-x86/android-depends.xml instead

  3. Run the following bash commands:

#rename platform.xml on iOS, we'll need this to get the extension back together
mv tmp/META-INF/ANE/iPhone-ARM/platform.xml tmp/META-INF/ANE/iPhone-ARM/platform-iOS.xml 

#pack the extension back with adt
cd tmp/META-INF/ANE/
“${flex.sdk}/bin/adt" -package -target ane PushNotification.ane extension.xml -swc ../../../../SWC-Pushwoosh/PushNotification.swc -platform iPhone-ARM -platformoptions iPhone-ARM/platform-iOS.xml -C iPhone-ARM/ . -platform Android-ARM -platformoptions Android-ARM/android-depends.xml -C Android-ARM/ . -platform Android-x86 -C Android-x86/ . -platformoptions Android-x86/android-depends.xml -platform default -C default/ .

You can find PushNotification.swc here: https://github.com/Pushwoosh/pushwoosh-adobe-air/blob/master/SWC-Pushwoosh/PushNotification.swc

4. Unreal Engine

Unreal Engine and Pushwoosh Plugin will almost always conflict with each other. This is explained by Unreal Engine containing Google Play services by default, and different versions of the Engine use different versions of these libs. Pushwoosh plugin uses these libs as well, however a bit different subset. You should be always careful when integrating Pushwoosh Plugin for Unreal Engine. Even if your project seems to compile and work well you should ensure that both Pushwoosh and Unreal Engine use the same version of Google Play Services. Usage of different versions of google-play-services in one project is "undefined behaviour"!

To resolve a conflict you should do the following:

1. Determine which Google Play services libraries are already used in a project. You can figure it out checking ${UNREAL_PROJECT}/Intermediate/Android/APK/JavaLibs and ${UNREAL_PROJECT}/Intermediate/Android/APK/libs directories. For example in the sample project created using Unreal Engine 4.15 there are following libraries:

JavaLibs:

  • downloader_library

  • play-services-ads-lite-9.2.0

  • play-services-auth-base-9.2.0

  • play-services-basement-9.2.0

  • play-services-drive-9.2.0

  • play-services-gass-9.2.0

  • play-services-plus-9.2.0

  • support-v4-23.0.0

  • play-services-ads-9.2.0

  • play-services-auth-9.2.0

  • play-services-base-9.2.0

  • play-services-clearcut-9.2.0

  • play-services-games-9.2.0

  • play-services-nearby-9.2.0

  • play-services-tasks-9.2.0

  • pushwoosh-ue-plugin // Added by Pushwoosh plugin

libs:

  • SystemUtils.jar

  • VrApi.jar

  • play-services-gcm-9.2.0.jar // Added by Pushwoosh plugin

  • play-services-iid-9.2.0.jar // Added by Pushwoosh plugin

2. If versions of play-services* libraries used in Pushwoosh and Unreal Engine does not match remove these libraries from Pushwoosh plugin.

2.1 Figure out which missing libraries you should add to Pushwoosh Plugin. The plugin requires android-support-v4, play-services-base, play-services-basement, play-services-gcm, play-services-iid libraries. For the sample project only play-services-gcm and play-services-iid does not overlap so they are only libraries that should be added in this particular case.

2.2 To add the library simply put .jar file from Android SDK in https://github.com/Pushwoosh/pushwoosh-unreal-engine/tree/master/Plugins/Pushwoosh/lib/Android/libs. The location of Goole Play libraries is described in the beginning of this article.

Share your feedback with us

Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.

Last updated

#1685:

Change request updated