React-native-fcm: Configuration Issue with react-native-maps

Created on 25 Jan 2017  路  12Comments  路  Source: evollu/react-native-fcm

react-native version 0.40.0
react-native-fcm version 5.0.0
device: HTC One M8 (Android Version 5.0.1)

I've gone through the build steps twice, and they both did not work. I continuously received this error when attempting react-native run-android :
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zze

I tried the example in the repo, and that works just fine. My second attempt used all of the same gradle, manifest, and MainApplication settings (other than other libraries), but did not work.

I was tipped off to a possible problem here:
http://stackoverflow.com/questions/38595171/duplicate-entry-com-google-firebase-firebaseapinotavailableexception-class
When I add multiDex, the exception turns into:
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zze.class

At this point, I manually modified the build.gradle for react-native-fcm in node_modules to use:
compile 'com.google.firebase:firebase-core:9.2.1' compile 'com.google.firebase:firebase-messaging:9.2.1'
and the error went away. Notice "9.2.1" instead of "+"

I am using react-native-maps. perhaps that's conflicting? The dependencies there are:
compile "com.google.android.gms:play-services-base:9.8.0" compile "com.google.android.gms:play-services-maps:9.8.0"

Most helpful comment

I've had the same issue using create-react-native-app ejected app. Replacing compile :react-native-fcm in app/build.gradle to

compile(project(':react-native-fcm')) {
    exclude module: 'react-native'
    exclude group: "com.google.firebase"
  }  

Here is good guide on gradle collisions: https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f

All 12 comments

After commenting out the react-native-maps dependency, the build worked... I'm not Android-saavy enough to figure out why, but I imagine it would be common to need to use both in an app.

Having the same issue

Having the same problem for 2 days now. Any tip on what to do anyone?

I removed react-native-fcm and moved to https://github.com/fullstackreact/react-native-firestack. It works well with react-native-maps.

It includes cloudMessaging and offers a lot of other nice features I inteded to use anyways, so it's more reasonable for me to use that instead.

Looks good but I initially steered clear because their readme doesn't state that it's available yet. I'll try it tommorrow. Thanks for the tip.

The version has to match. Change 9.2.1 to be the same as react-native-map (9.8.0?) and it should work. You can use resolutionStrategy in you gradle file to decide what version of playservice to use.
@DavidKuennen I checked react-native-firestack and notice them locking to 10.0.1. Do you have to turn on any flag to make it coexist with react-native-maps?

@evollu Yeah, I changed the dependencies of react-native-maps to
compile "com.google.android.gms:play-services-base:+"
compile "com.google.android.gms:play-services-maps:+"

I believe the issue is major version conflicts. as + resolves to latest version available (currently 10.+), it can't coexist with 9.x libraries. Having resolutionsStrategy controlling version is the best way I can think of.

u can force a specifc version like this

dependencies {
    ...
    compile ('com.android.support:appcompat-v7:25.0.1') {
        exclude group: 'com.google.android', module: 'support-v4'
    }
    compile ('com.google.android.gms:play-services-gcm:10.0.1') {
        force = true;
    }
   ...
}

Thanks @sibelius !
Firestack actually wasn't working for me.
The force = true allowed react-native-fcm to work with react-native-maps perfectly.

@sibelius I will add your solution to readme.

I've had the same issue using create-react-native-app ejected app. Replacing compile :react-native-fcm in app/build.gradle to

compile(project(':react-native-fcm')) {
    exclude module: 'react-native'
    exclude group: "com.google.firebase"
  }  

Here is good guide on gradle collisions: https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f

Was this page helpful?
0 / 5 - 0 ratings