question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This plugin is conflicting with Firebase Cloud Messaging

See original GitHub issue

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

Your Environment

    @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

Context

Expected Behavior

Expect it to compile

Actual Behavior

Compilation fails with DEX-error

  • What went wrong: Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Possible Fix

None found

Steps to Reproduce

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 angularfire2@5.0.0-rc.6 firebase@4.9.0

(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

Context

Unable to combine notifications and geolocation

Debug logs

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
ThorvaldAagaardcommented, Jun 9, 2018

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

1reaction
ThorvaldAagaardcommented, Aug 23, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin and Version Conflict with Firebase Messaging
Firebase Messaging (7.0.2) requires Firebase Core 0.5.1 whereas the Cloud Firestore plugin needs Firebase Core 0.7.0.
Read more >
Plugin and Version Conflict with Firebase Messaging-Flutter
Coding example for the question Plugin and Version Conflict with Firebase Messaging-Flutter.
Read more >
Cordova plugin conflict with both fcm and googleplus - ionic-v3
Hi , I have conflict with two plugin of cordova. 1.) cordova-plugin-FCM (Firebase cloud messaging). 2.)cordova-plugin-googleplus.
Read more >
Dependencies of Firebase Android SDKs on Google Play ...
Some Firebase Android SDKs depend on Google Play services, which means they will only run on devices and emulators with Google Play services...
Read more >
Release Notes - Play services - Google Developers
Firebase Android BoM (Bill of Materials); Cloud Firestore; Firebase App Distribution Gradle plugin; Firebase Authentication; Firebase Cloud Messaging.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found