我已经添加了"react-native-push-notification“包,并遵循了手动iOS和android的链接过程。该应用程序在iOS上运行良好,但在安卓系统上运行时显示以下错误:
...
: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我不知道哪里出了问题。我完全按照文档中所示的流程操作。
发布于 2017-02-01 18:45:46
结果是我添加了错误的Google Play Service版本(文档中有)。
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文件中。它解决了这个问题。
https://stackoverflow.com/questions/41977752
复制相似问题