How to use ngcordova facebook and push notificatio

2019-05-31 06:05发布

问题:

when i am using ngCordova facebook and pushNotification plugins in same app and build the app then find the following error.

======================================================================== UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106)

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':dexDebug'.

    com.android.ide.common.internal.LoggedErrorException: Failed to run command: /opt/android-sdk-linux/build-tools/23.0.1/dx --dex --no-optimize --output /home/anurag/my-works/fbPush/platforms/android/build/intermediates/dex/debug --input-list=/home/anurag/my-works/fbPush/platforms/android/build/intermediates/tmp/dex/debug/inputList.txt Error Code: 2 Output:

    UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106)

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 38.579 secs

/home/anurag/my-works/fbPush/platforms/android/cordova/node_modules/q/q.js:126 throw e; ^ Error code 1 for command: /home/anurag/my-works/fbPush/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/anurag/my-works/fbPush/platforms/android/build.gradle,-Dorg.gradle.daemon=true

回答1:

I had the same issue on my app and i solved it by removing my cordova facebook plugin and adding this one : https://github.com/jeduan/cordova-plugin-facebook4

My push notification plugin is : phonegap-plugin-push