React-native-push-notification: Build fails on Android 4.4.2 [email protected]

Created on 21 Sep 2016  路  3Comments  路  Source: zo0r/react-native-push-notification

First of all, thank you for this plugin!

I've installed 2.1.1 plugin version. In componentDidMount I configure plugin. Application crashed after launch. Commenting configure method prevented from crashing.
Then I've updated Google Play Services and Build Tools to latest. Build failed with this:

:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/iid/MessengerCompat$1;
Unknown source file :   at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file :   at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file :   at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file :   at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file :   at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file :   at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file :   at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file :   at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file :   at com.android.dx.command.Main.main(Main.java:106)
  • Plugin version: 2.1.1
  • Platform: Android
  • OS version: 4.4.2
  • Device manufacturer and model: Alcatel One Touch P310X
  • React Native version: 0.33.0

    Plugin configuration options:

PushNotification.configure({
  onRegister: function(token) {
    console.log( 'TOKEN:', token );
  },
  onNotification: function(notification) {
    console.log( 'NOTIFICATION:', notification );
  },)
  senderID: "MY_ID",
  requestPermissions: true,
});

Plugins in package.json

"react-native-auto-updater": "^0.2.5",
"react-native-background-timer": "^0.1.2",
"react-native-idle-timer": "^2.1.0",
"react-native-linear-gradient": "^1.5.12",
"react-native-material-switch": "git+https://github.com/recr0ns/react-native-material-switch.git",
"react-native-mauron85-background-geolocation": "git+https://github.com/mauron85/react-native-background-geolocation.git#issue10",
"react-native-push-notification": "^2.1.1",
"react-native-side-menu": "^0.19.0",
"react-native-webview-bridge": "git+https://github.com/alinz/react-native-webview-bridge.git",

I assume that problem caused by Google Play Services, but don't know what exactly it is.

Most helpful comment

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

All 3 comments

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

tnx ! how do i check which version i have ? just changed to this and it worked

For me, I just had to upgrade gradle. Maybe a newer version of gradle handles these conflicts better.

Was this page helpful?
0 / 5 - 0 ratings