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

时间:2015-03-30 11:01:44

标签: android android-support-library

意外的顶级例外情况: com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536 错误:任务':app:dexDebug'。

的执行失败
  

com.android.ide.common.internal.LoggedErrorException:无法运行命令:       /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     错误代码:       2     输出:       意外的顶级例外情况:       com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536           在com.android.dx.merge.DexMerger $ 6.updateIndex(DexMerger.java:502)           在com.android.dx.merge.DexMerger $ IdMerger.mergeSorted(DexMerger.java:277)           在com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)           在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)           在com.android.dx.merge.DexMerger.merge(DexMerger.java:189)           在com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)           在com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)           在com.android.dx.command.dexer.Main.run(Main.java:245)           在com.android.dx.command.dexer.Main.main(Main.java:214)           在com.android.dx.command.Main.main(Main.java:106)

1 个答案:

答案 0 :(得分:10)

您遇到方法计数限制。您可以使用multidex或减少方法的数量(例如使用proguard) 请阅读:https://developer.android.com/tools/building/multidex.html