【问题标题】:DexIndexOverflowException: Cannot merge new index 65772 into a non-jumbo instruction!: Jumbo Mode? and/or Multi-Dex? What is behind the scene?DexIndexOverflowException:无法将新索引 65772 合并到非巨型指令中!:巨型模式?和/或 Multi-Dex?幕后是什么?
【发布时间】:2015-05-28 19:12:01
【问题描述】:

我已经尝试在我的项目的gradle中设置jumboMode,它似乎能够解决以下DexIndexOverflowException:

com.android.dex.DexException:无法将新索引 65536 合并到非巨型指令中!

DexIndexOverflowException:无法将新索引 65772 合并到非巨型指令中!

1) jumboMode 选项在幕后的实际作用是什么?

android {
    ...
    dexOptions {
        jumboMode true
    }

}

2) 我也注意到启用 multi-dex 也可以解决同样的问题,这两种方法之间的正确选择是什么?

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

【问题讨论】:

标签: android mode dex android-multidex


【解决方案1】:

“Jumbo”的意思是“和以前一样,但有大量的参考资料”。

DEX 文件中几乎所有内容都引用了 16 位值(甚至字节码都以 16 位“单元”形式存在),因此这里只能处理 65536 个对象(方法或字符串),仅此而已。

但是应用程序可以包含更多的字符串!如何解决这个限制? Android 的开发人员刚刚添加了带有“jumbo”后缀的新操作码,因此您可以使用“const-string 16_bit_addr”或“const-string 32_bit_addr”来引用字符串,它们可以引用 2^32 个项目。目前https://source.android.com/devices/tech/dalvik/dalvik-bytecode“jumbo”后缀只存在于字符串(const-string/jumbo),但在旧文档中包含:

#
# Extended-width opcodes
#

op 00ff const-class/jumbo           41c  y type-ref      continue|throw
op 01ff check-cast/jumbo            41c  n type-ref      continue|throw
op 02ff instance-of/jumbo           52c  y type-ref      continue|throw
op 03ff new-instance/jumbo          41c  y type-ref      continue|throw
op 04ff new-array/jumbo             52c  y type-ref      continue|throw
op 05ff filled-new-array/jumbo      5rc  n type-ref      continue|throw
op 06ff iget/jumbo                  52c  y field-ref     continue|throw
op 07ff iget-wide/jumbo             52c  y field-ref     continue|throw
op 08ff iget-object/jumbo           52c  y field-ref     continue|throw
op 09ff iget-boolean/jumbo          52c  y field-ref     continue|throw
op 0aff iget-byte/jumbo             52c  y field-ref     continue|throw
op 0bff iget-char/jumbo             52c  y field-ref     continue|throw
op 0cff iget-short/jumbo            52c  y field-ref     continue|throw
op 0dff iput/jumbo                  52c  n field-ref     continue|throw
op 0eff iput-wide/jumbo             52c  n field-ref     continue|throw
op 0fff iput-object/jumbo           52c  n field-ref     continue|throw
op 10ff iput-boolean/jumbo          52c  n field-ref     continue|throw
op 11ff iput-byte/jumbo             52c  n field-ref     continue|throw
op 12ff iput-char/jumbo             52c  n field-ref     continue|throw
op 13ff iput-short/jumbo            52c  n field-ref     continue|throw
op 14ff sget/jumbo                  41c  y field-ref     continue|throw
op 15ff sget-wide/jumbo             41c  y field-ref     continue|throw
op 16ff sget-object/jumbo           41c  y field-ref     continue|throw
op 17ff sget-boolean/jumbo          41c  y field-ref     continue|throw
op 18ff sget-byte/jumbo             41c  y field-ref     continue|throw
op 19ff sget-char/jumbo             41c  y field-ref     continue|throw
op 1aff sget-short/jumbo            41c  y field-ref     continue|throw
op 1bff sput/jumbo                  41c  n field-ref     continue|throw
op 1cff sput-wide/jumbo             41c  n field-ref     continue|throw
op 1dff sput-object/jumbo           41c  n field-ref     continue|throw
op 1eff sput-boolean/jumbo          41c  n field-ref     continue|throw
op 1fff sput-byte/jumbo             41c  n field-ref     continue|throw
op 20ff sput-char/jumbo             41c  n field-ref     continue|throw
op 21ff sput-short/jumbo            41c  n field-ref     continue|throw
op 22ff invoke-virtual/jumbo        5rc  n method-ref    continue|throw|invoke
op 23ff invoke-super/jumbo          5rc  n method-ref    continue|throw|invoke
op 24ff invoke-direct/jumbo         5rc  n method-ref    continue|throw|invoke
op 25ff invoke-static/jumbo         5rc  n method-ref    continue|throw|invoke
op 26ff invoke-interface/jumbo      5rc  n method-ref    continue|throw|invoke

【讨论】:

    猜你喜欢
    • 2014-02-22
    • 2014-11-23
    • 2014-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-08
    • 1970-01-01
    相关资源
    最近更新 更多