{"_id":"5742d9f64a7a4b0e00facecf","category":{"_id":"5540e5f131827a0d007ab212","__v":15,"project":"5540ce1b31827a0d007ab1cc","pages":["5540e66b31827a0d007ab217","5540e67731827a0d007ab219","55ac917b5863b817008ae3b4","55acaa4c6b4ff90d00784a92","55acb96418eefd0d0071d553","55acc8aa18eefd0d0071d596","55accd2818eefd0d0071d5a8","55acd06518eefd0d0071d5b6","55acddd7fb7b3c19003739cc","55ace14bfb7b3c19003739d3","55ace3a9fb7b3c19003739d7","55acea24f93f0c0d005b880f","55acf15bf93f0c0d005b8821","55acf3cd18eefd0d0071d5fb","55d1f1c0486de50d00326f17"],"version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T14:08:49.271Z","from_sync":false,"order":4,"slug":"android","title":"Android"},"project":"5540ce1b31827a0d007ab1cc","version":{"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","__v":31,"createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"user":"5540e0f5bb9e762d00f594c0","__v":9,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-23T10:22:46.876Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"Welcome to the **google-play-services** library nightmare :)\n\nIn 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.\n\nMost of the time it is up to you to solve these conflicts. Fortunately, this can be fixed. Below are solutions for different plugins.\n\nYou can always find the Google Play Services library at **<Android SDK>/extras/google**\nLibrary is available as one big fat** jar** file: *sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar*\nAs well as other small** aar** files (stands for Android Archive): *sdk/extras/google/m2repository/com/google/android/gms/…*\n\n**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.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Cordova\"\n}\n[/block]\nAll 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.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Unity, Appcelerator Titanium\"\n}\n[/block]\nYou can find Google Play Services library in the plugin (or sample project), they are easy to updatge/change/remove to solve possible conflicts:\n\n* Unity:\nhttps://github.com/Pushwoosh/pushwoosh-unity/tree/master/PushwooshUnitySample/Assets/Plugins/Android\n\n* Unity and Google Analytics plugin:\nGoogle analytics plugin uses an outdated google play library, which needs to be updated. More info here: https://github.com/Pushwoosh/pushwoosh-unity/issues/5\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"rm -rf Assets/Plugins/Android/google-play-services_lib/libs\\nrm -rf Assets/Plugins/Android/google-play-services_lib/res\\ncp ${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/\\ncp ${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/\\n\",\n      \"language\": \"shell\",\n      \"name\": \"Bash\"\n    }\n  ]\n}\n[/block]\n* Appcelerator Titanium (note the version of the module may change faster than this document!):\nhttps://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Push-Notifications-Module/modules/android/com.pushwoosh.module/\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Adobe Air\"\n}\n[/block]\nA useful article:\nhttp://blogs.adobe.com/airodynamics/2014/06/13/using-multiple-anes-having-common-jars-as-packageddependency/\n\nTake the ANE extension, rip it apart and sew it back together again.\nHere is a working example with **PushNotification.ane**:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"unzip PushNotification.ane -d tmp\",\n      \"language\": \"shell\",\n      \"name\": \"Bash\"\n    }\n  ]\n}\n[/block]\nThe command line above tells to extract the contents of the .ane file to the *tmp *directory.\n \nNow 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.\n\nIf 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.\n\nwell...\n\n> PushNotification.ane is not a valid native extension file.\n \nIt's a bit trickier to sew the extension back together:\n \n1. Delete *tmp/META-INF/ANE/Android-ARM/platform.xml* and *tmp/META-INF/ANE/Android-x86/platform.xml*\n2. 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\n3. Run the following bash commands:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#rename platform.xml on iOS, we'll need this to get the extension back together\\nmv tmp/META-INF/ANE/iPhone-ARM/platform.xml tmp/META-INF/ANE/iPhone-ARM/platform-iOS.xml \\n\\n#pack the extension back with adt\\ncd tmp/META-INF/ANE/\\n“${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/ .\",\n      \"language\": \"shell\",\n      \"name\": \"Bash\"\n    }\n  ]\n}\n[/block]\nYou can find PushNotification.swc here: \nhttps://github.com/Pushwoosh/pushwoosh-adobe-air/blob/master/SWC-Pushwoosh/PushNotification.swc\n[block:api-header]\n{\n  \"title\": \"4. Unreal Engine\"\n}\n[/block]\nUnreal 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\"!\n\nTo resolve a conflict you should do the following:\n\n**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](https://github.com/Pushwoosh/pushwoosh-unreal-engine) created using Unreal Engine 4.15 there are following libraries:\n\nJavaLibs:\n * downloader_library \n * play-services-ads-lite-9.2.0 \n * play-services-auth-base-9.2.0 \n * play-services-basement-9.2.0 \n * play-services-drive-9.2.0 \n * play-services-gass-9.2.0 \n * play-services-plus-9.2.0 \n * support-v4-23.0.0\n * play-services-ads-9.2.0\n * play-services-auth-9.2.0 \n * play-services-base-9.2.0 \n * play-services-clearcut-9.2.0 \n * play-services-games-9.2.0 \n * play-services-nearby-9.2.0 \n * play-services-tasks-9.2.0\n * pushwoosh-ue-plugin // Added by Pushwoosh plugin\n\nlibs:\n * SystemUtils.jar\t\t\t\n * VrApi.jar\n * play-services-gcm-9.2.0.jar // Added by Pushwoosh plugin\n * play-services-iid-9.2.0.jar // Added by Pushwoosh plugin\n\n**2.** If versions of play-services* libraries used in Pushwoosh and Unreal Engine does not match remove these libraries from [Pushwoosh plugin](https://github.com/Pushwoosh/pushwoosh-unreal-engine/tree/master/Plugins/Pushwoosh/lib/Android/libs).\n\n**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. \n\n**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.","excerpt":"","slug":"resolving-google-play-services-conflicts","type":"basic","title":"Resolving Google Play Services conflicts"}

Resolving Google Play Services conflicts


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. [block:api-header] { "type": "basic", "title": "1. Cordova" } [/block] 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. [block:api-header] { "type": "basic", "title": "2. Unity, Appcelerator Titanium" } [/block] You can find Google Play Services library in the plugin (or sample project), they are easy to updatge/change/remove to solve possible conflicts: * Unity: https://github.com/Pushwoosh/pushwoosh-unity/tree/master/PushwooshUnitySample/Assets/Plugins/Android * Unity and Google Analytics plugin: Google analytics plugin uses an outdated google play library, which needs to be updated. More info here: https://github.com/Pushwoosh/pushwoosh-unity/issues/5 [block:code] { "codes": [ { "code": "rm -rf Assets/Plugins/Android/google-play-services_lib/libs\nrm -rf Assets/Plugins/Android/google-play-services_lib/res\ncp ${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/\ncp ${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/\n", "language": "shell", "name": "Bash" } ] } [/block] * Appcelerator Titanium (note the version of the module may change faster than this document!): https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/tree/master/Push-Notifications-Module/modules/android/com.pushwoosh.module/ [block:api-header] { "type": "basic", "title": "3. Adobe Air" } [/block] A useful article: http://blogs.adobe.com/airodynamics/2014/06/13/using-multiple-anes-having-common-jars-as-packageddependency/ Take the ANE extension, rip it apart and sew it back together again. Here is a working example with **PushNotification.ane**: [block:code] { "codes": [ { "code": "unzip PushNotification.ane -d tmp", "language": "shell", "name": "Bash" } ] } [/block] 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: [block:code] { "codes": [ { "code": "#rename platform.xml on iOS, we'll need this to get the extension back together\nmv tmp/META-INF/ANE/iPhone-ARM/platform.xml tmp/META-INF/ANE/iPhone-ARM/platform-iOS.xml \n\n#pack the extension back with adt\ncd tmp/META-INF/ANE/\n“${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/ .", "language": "shell", "name": "Bash" } ] } [/block] You can find PushNotification.swc here: https://github.com/Pushwoosh/pushwoosh-adobe-air/blob/master/SWC-Pushwoosh/PushNotification.swc [block:api-header] { "title": "4. Unreal Engine" } [/block] 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](https://github.com/Pushwoosh/pushwoosh-unreal-engine) 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](https://github.com/Pushwoosh/pushwoosh-unreal-engine/tree/master/Plugins/Pushwoosh/lib/Android/libs). **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.