【问题标题】:"react-native-push-notification" package causing multiple dex debug error on android“react-native-push-notification”包在 android 上导致多个 dex 调试错误
【发布时间】:2017-02-01 10:45:45
【问题描述】:

我已经添加了包“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

我不确定出了什么问题。我完全按照文档中的说明进行操作。

【问题讨论】:

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


    【解决方案1】:

    事实证明,我添加了错误的 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 文件中。它解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2018-12-16
      • 1970-01-01
      • 1970-01-01
      • 2023-01-09
      • 2018-02-05
      • 1970-01-01
      • 1970-01-01
      • 2018-12-29
      • 1970-01-01
      相关资源
      最近更新 更多