cordova build android get Execution failed for task ':dexArmv7Debug'

本篇文章由:http://xinpure.com/cordova-build-android-get-execution-failed-for-task-dexarmv7debug/

XGPush 腾讯信鸽推送 for Cordova

Build 过程及错误原因

Cordova 项目原本是可以正常的 build,在添加了 XGPush 之后就出错了。。。

Input:

cordova build android

Output:

:dexArmv7Debug

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    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)

:dexArmv7Debug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dexArmv7Debug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/xinpure/android-sdk/build-tools/23.0.2/dx --dex --no-optimize --output /Project/gacha-app-hybrid/platforms/android/build/intermediates/dex/armv7/debug --input-list=/Project/gacha-app-hybrid/platforms/android/build/intermediates/tmp/dex/armv7/debug/inputList.txt
  Error Code:
    2
  Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
        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)

错误解决方法

添加 XGPush 之后,会在 android/libs 目录下添加一个 android-support-v4.jar, 将此 jar 文件删除即可。

参考链接

https://github.com/phonegap/phonegap-plugin-push/issues/159

http://stackoverflow.com/questions/26342444/multiple-dex-files-define-landroid-support-annotation-animres

posted @ 2015-11-07 00:54  xinpureZhu  阅读(515)  评论(0编辑  收藏  举报