I have an existing application where I would like to use Firebase Cloud Messaging like described on
https://angularfirebase.com/lessons/ionic-native-with-firebase-fcm-push-notifications-ios-android/
After following this guide my app can no longer compile - seems to be a problem with mixed version of google-play-services.
Starting from an empty project I have managed to reproduce the error from a blank starter project and following the guide (all works) and then adding the background location plugin and now it fails
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.9
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.9.3
npm : 5.5.1
OS : Windows 10
Environment Variables:
ANDROID_HOME : D:\Documents\Android\Sdk
Expect it to compile
Compilation fails with DEX-error
None found
I have now done a lot more testing, and I am able to reproduce the error following the following steps
ionic start demoapp
cd demoapp
npm install
ionic cordova plugin add cordova-plugin-firebase
npm install --save @ionic-native/firebase
npm install --save [email protected] [email protected]
(need to install these versions as newer version are not compatible with ionic 3 as it uses angular6)
ionic cordova build android
(notice this builds ok)
ionic cordova plugin add cordova-plugin-mauron85-background-geolocation
ionic cordova build android
(this will give a compile error as there are conflicting versions of google-play-services)
ionic cordova plugin add cordova-android-play-services-gradle-release
(this plugin aligns the google-play-service versions)
ionic cordova build android
Now I get the DEX-error
37 actionable tasks: 1 executed, 36 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:57812) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:57812) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
So it looks like a conflict between the 2 plugins, but I haven't found a way to compile the solution, so any suggestions are welcome
Unable to combine notifications and geolocation
You can override google play version used by this plugin. Read the docs for instructions
Yes, as I wrote I installed cordova-android-play-services-gradle-release and that removed the compile error, and introduced the DEX-error.
I did not find any documentation of how to change
<variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
so I just left it, as I assumed it would use whatever cordova-android-play-services-gradle-release was setting up
But as you wrote in the readme, the DEX could also be an issue with the support libraries, so I add a 3rd plugin for managing these libraries
<plugin name="cordova-android-play-services-gradle-release" spec="^1.4.2">
<variable name="PLAY_SERVICES_VERSION" value="15.0.0" />
</plugin>
<plugin name="cordova-android-firebase-gradle-release" spec="^1.0.1">
<variable name="FIREBASE_VERSION" value="15.0.0" />
</plugin>
<plugin name="cordova-android-support-gradle-release" spec="^1.4.3">
<variable name="ANDROID_SUPPORT_VERSION" value="26.+" />
</plugin>
And VOILA !! - Now it compiles, and you are welcome to close this issue, but should probably consider adding a link to these plugins as they are solving a problem
@ThorvaldAagaard, i try your advice with cordova-plugin-google-analytics and firebase plugin but doesn't work, any additional advice ?
The error reoccured when upgrading some of the plugins, and that is probably what the problem you have
I ended up removing all the plugins that updated the play services, and changed my configuration to
<plugin name="cordova-plugin-mauron85-background-geolocation" spec="^3.0.0-alpha.38">
<variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
<variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
but I am migrating to Ionic-V4 and it will be interesting to see how that will go
I got same error when use cordova-plugin-fcm with this plugin.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.+.
@ThorvaldAagaard bro does it matter for ios deployment as i am unable to build in ios in xcode 10.1 ?
@sibabratswain11 As long as it builds you should be fine - In my project we are moving away from cordova-plugin-fcm and will try to use cordova-plugin-firebase-messaging
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.
Most helpful comment
Yes, as I wrote I installed cordova-android-play-services-gradle-release and that removed the compile error, and introduced the DEX-error.
I did not find any documentation of how to change
so I just left it, as I assumed it would use whatever cordova-android-play-services-gradle-release was setting up
But as you wrote in the readme, the DEX could also be an issue with the support libraries, so I add a 3rd plugin for managing these libraries
And VOILA !! - Now it compiles, and you are welcome to close this issue, but should probably consider adding a link to these plugins as they are solving a problem