我不完全确定将dex选项“jumbomode”设置为true与添加multidex支持之间的区别是什么。
将jumbo模式设置为true或将multidex设置为true似乎可以解决下面的问题
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexIndexOverflowException: Cannot merge new index 65772 into a non-jumbo instruction!","position":{},"original":"com.android.dex.DexIndexOverflowException: Cannot merge new index 65772 into a non-jumbo instruction!"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)","position":{},"original":"\tat com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)","position":{},"original":"\tat com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)"}
...
答案 0 :(得分:27)
Jumbo模式,阅读时 https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html,const-string / jumbo是字符串的巨型模式。这是关于操作码," op vAA,string @ BBBBBBBB" vs" op vAA,string @ BBBB",32位与16位。
Multi Dex 允许从多个dex文件加载类。主classes.dex必须包含调用此类方法所需的类。首次调用MultiDex.install(Context)后,应用程序apk中的辅助dex文件将被添加到类加载器中 见https://developer.android.com/reference/android/support/multidex/MultiDex.html
答案 1 :(得分:7)
看看这个(搜索jumbo):
简而言之: - 类似于Android方法计数限制(64K) - 字符串数量限制(64K) - 要克服此限制 - jumbo模式允许通过使用特殊的opCode来引用超过2 ^ 16个字符串,该opCode最多可编码2 ^ 32个字符串。
实践中: - 根据我的经验,(MultiDex和JumboMode)对apk安装时间(慢得多)有重大影响。
希望这有助于:)