{"__v":9,"_id":"5742d9f64a7a4b0e00facecf","category":{"__v":15,"_id":"5540e5f131827a0d007ab212","pages":["5540e66b31827a0d007ab217","5540e67731827a0d007ab219","55ac917b5863b817008ae3b4","55acaa4c6b4ff90d00784a92","55acb96418eefd0d0071d553","55acc8aa18eefd0d0071d596","55accd2818eefd0d0071d5a8","55acd06518eefd0d0071d5b6","55acddd7fb7b3c19003739cc","55ace14bfb7b3c19003739d3","55ace3a9fb7b3c19003739d7","55acea24f93f0c0d005b880f","55acf15bf93f0c0d005b8821","55acf3cd18eefd0d0071d5fb","55d1f1c0486de50d00326f17"],"project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T14:08:49.271Z","from_sync":false,"order":4,"slug":"android","title":"Android"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"5540e0f5bb9e762d00f594c0","version":{"__v":31,"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","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"},"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":6,"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]\nOne of the best frameworks. It supports **gradle **builds and the library is simply referenced from the plugin: \nhttps://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/09beb45bbe8334844733f126a5aa0d99062882cf/plugin.xml#L138\n\nWorks perfectly everywhere.\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","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] One of the best frameworks. It supports **gradle **builds and the library is simply referenced from the plugin: https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/09beb45bbe8334844733f126a5aa0d99062882cf/plugin.xml#L138 Works perfectly everywhere. [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