当我尝试在Android Studio中运行我的项目时,收到以下错误消息
Execution failed for task ':CricHQ:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/19.0.1/dx -JXmx4g --dex --output
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Cannot merge new index 66514 into a non-jumbo instruction!
at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:108)
at com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:25)
at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:71)
at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:48)
at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:840)
at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:811)
at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:783)
at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:680)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:540)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
任何人都可以帮我解决这个问题吗?非常感谢。
答案 0 :(得分:17)
如果你使用的是没有gradle的Android Studio,那么Preferences-> Compiler-> Android Compilers-> Force Jumbo Mode
如果您使用gradle,则添加到build.gradle
android {
dexOptions {
jumboMode true
}
答案 1 :(得分:8)
在Android中,您可以在单个dex文件中拥有Java方法的数量,并且您已达到该限制。不幸的是,它没有简单的解决方案。您的选择是:
如果这些方法不起作用,可以将应用程序拆分为多个dex文件,并使用类加载器技巧使其在运行时工作,但这更复杂。