“react-native-push-notification”包导致android

时间:2017-02-01 10:45:46

标签: android push-notification react-native react-native-android

我添加了包“react-native-push-notification”并按照手动iOS和android链接过程。该应用程序在iOS上运行良好,但在Android上运行时显示以下错误:

...
:app:preDexDebug
: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)

:app:dexDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

我不确定出了什么问题。我完全按照文档中的说明执行了该过程。

1 个答案:

答案 0 :(得分:0)

事实证明我添加了错误的Google Play服务版本(存在于文档中)。

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

我已将其更改为:

compile project(':react-native-push-notification')
compile ('com.google.android.gms:play-services-gcm:9.4.0') {
  force = true;
}

android/app/build.gradle文件中。它解决了这个问题。