2015-05-28 60 views
22

我不完全確定將dex選項「jumbomode」設置爲true與添加multidex支持之間的區別。Android:Jumbo模式與Multidex

設置巨型模式爲真或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)"} 
... 
+2

的可能的複製[DexIndexOverflowException:不能合併新的索引65772到非巨型指令!:巨型模式?和/或Multi-Dex?幕後是什麼?(https://stackoverflow.com/questions/30515209/dexindexoverflowexception-cannot-merge-new-index-65772-into-a-non-jumbo-instruc) –

回答

26

巨型模式,閱讀 https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html時,該常量字符串/巨型是串巨型模式的問題。它關於操作碼,使得「op vAA,string @ BBBBBBBB」對比「op vAA,string @ BBBB」,32位對比16位。

Multi Dex允許從多個dex文件中加載類。主classes.dex必須包含調用此類方法所需的類。在應用APK發現二次DEX文件將被添加到類加載器MultiDex.install第一次調用(上下文) 看到https://developer.android.com/reference/android/support/multidex/MultiDex.html

5

看看這個後(搜索珍寶):

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

簡而言之: - 類似於Android方法計數限制(64K) - 字符串計數有限制(64K) - 爲了克服這個限制 - 巨型模式允許通過使用特殊的opCode來引用超過2^16個字符串,到2^32個字符串。

在實踐中: - 從我的經驗(MultiDex & JumboMode)對apk安裝時間有很大影響(慢得多)。

希望這有助於:)