为什么会这样?我该如何解决? Android:意外的顶级例外:

前端之家收集整理的这篇文章主要介绍了为什么会这样?我该如何解决? Android:意外的顶级例外:前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > Weird : UNEXPECTED TOP-LEVEL EXCEPTION: Execution failed for task app:dexDebug4个
意外的顶级例外:
com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536
错误:任务’:app:dexDebug’的执行失败.

com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/prem/Development/Android-sdk/sdk/build-tools/21.0.1/dx –dex –no-optimize –output /home/prem/currencysave/Android/CurrencySave/app/build/intermediates/dex/debug –input-list=/home/prem/currencysave/Android/CurrencySave/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0,0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)

解决方法

你遇到了方法计数限制.要么使用multidex,要么减少方法数量(例如使用proguard)
请阅读: https://developer.android.com/tools/building/multidex.html

猜你在找的Android相关文章