用于Gradle构建的dexOptions中的jumboMode的目的是什么? [英] What is the purpose of jumboMode in dexOptions for a Gradle build?

查看:2407
本文介绍了用于Gradle构建的dexOptions中的jumboMode的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这篇文章,它允许dex文件中有更多的字符串,但我并不真正了解它的意义和对构建的影响。

解决方案


Jumbo模式属于可以在
a DEX文件中被引用,默认情况下,它使用16位宽整数进行索引。
因此,如果您的应用程序编码超过2 ^ 16个字符串,那么dx
工具也会失败。但是,对于字符串引用,有一个
补救措施:DEX支持允许32位宽
字符串引用的巨型操作码。 Android Gradle构建
脚本中的jumboMode标志启用此模式,允许最多2 ^ 32个字符串为
引用。


这意味着如果你的dex文件中有超过2 ^ 16个引用,你可以使用 jumboMode 来适应这个,最多允许2 ^ 32参考。这是通过强制字节码始终使用巨型字符串(2 ^ 32)引用来帮助避免合并dex文件时出现的问题。



注意:这不是与方法引用的数量有关,所以当你的dex文件有超过64k的方法时,这种模式并不能解决问题。



来源: https://开发者.soundcloud.com / blog / congratulations-you-have-a-lot-of-code-remedying-androids-method-limit-part-1

根据我的经验,除了可能增加构建时间之外,这不应该对构建产生任何显着影响。


According to this post it allows a larger number of strings in the dex files but I don't really understand what it means and the impact on builds.

解决方案

Jumbo mode pertains to the number of strings that can be referenced in a DEX file, which by default are indexed using 16 bit wide integers. Therefore, if your application encodes more than 2^16 strings, the dx tool will fail as well. For string references however, there is a remedy: DEX supports "jumbo opcodes" which allow for 32 bit wide string references. The jumboMode flag in an Android Gradle build script enables this mode, allowing up to 2^32 strings to be referenced.

What this means is if you have more than 2^16 references in your dex files, you can use jumboMode to accommodate for this by allowing up to 2^32 references. This is done by forcing the byte code to always use "jumbo strings" (2^32) references to help avoid issues when merging dex files.

Note: this does NOT have anything to do with the number of method references, so this mode doesn't solve when your dex file has more than 64k methods.

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

In my experiences, this shouldn't have any noticeable impact on builds other than a potential increase in build time.

这篇关于用于Gradle构建的dexOptions中的jumboMode的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆