Android:Jumbo Mode vs Multidex

我不完全确定将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)"} ... 

Jumbo Mode ,当阅读https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html时 ,const-string / jumbo是字符串的巨型模式。 它是关于操作码,“op vAA,string @ BBBBBBBB”与“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

看看这个(搜索jumbo):

https://developers.soundcloud.com/blog/congratulations-you-have-a-lot-of-code-remedying-androids-method-limit-part-1

简而言之: – 类似于Android方法计数限制(64K) – 字符串数量限制(64K) – 要克服此限制 – jumbo模式允许通过使用特殊的opCode来引用超过2 ^ 16个字符串,该编码最多可以编码2 ^ 32个字符串。

在实践中: – 根据我的经验,两者(MultiDex和JumboMode)对apk安装时间(慢得多)有重大影响。

希望这可以帮助:)