React-native-push-notification: Can't build for Android probably due to a conflict of Google Play Services

Created on 12 Jan 2018  路  4Comments  路  Source: zo0r/react-native-push-notification

I setup my app with 'react-native-firebase' to receive the notifications. The problem now is that I have to find a way to show the notifications

I installed react-native-push-notifications and now I cant build the prpject anymore. I get the error at 96%

" UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define"

It seems to be a conflict with the two libraries. How can i fix it?

Stale

Most helpful comment

I solved the same issue by changing the line in the dependencies section of android/app/build.gradle from
compile project(':react-native-push-notification')
to

compile(project(':react-native-push-notification')) {
    exclude group: "com.google.android.gms"
}

mimicking what was done in this post.

All 4 comments

That first error can be solved by adding:

android {
    defaultConfig {
       multiDexEnabled true
    }
}

But then you get a second one, which is the following one:

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/iid/zzb$zza;

Still no clue on how to solve it.

UPDATE: Found it in another answer.

Make sure to update all of these (if you have one or any) to the latest by adding a + like so:

 compile 'com.google.android.gms:play-services-gcm:+'
 compile 'com.google.android.gms:play-services-analytics:+'
 compile 'com.google.android.gms:play-services-location:+'

For anybody looking for an answer.

I solved this problem by replacing:

compile ('com.google.android.gms:play-services-gcm:8.1.0') {
    force = true;
}

with:

compile ('com.google.android.gms:play-services-gcm:11.8.0') {
    force = true;
}

in android/app/build.gradle.

I solved the same issue by changing the line in the dependencies section of android/app/build.gradle from
compile project(':react-native-push-notification')
to

compile(project(':react-native-push-notification')) {
    exclude group: "com.google.android.gms"
}

mimicking what was done in this post.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cookienawer picture cookienawer  路  3Comments

ssolida picture ssolida  路  3Comments

halaharr picture halaharr  路  3Comments

selimonline picture selimonline  路  3Comments

nidzovito picture nidzovito  路  3Comments