android - 用于 Gradle 构建的 dexOptions 中的 jumboMode 的目的是什么?

标签 android gradle

根据 this post它允许在 dex 文件中使用更多的字符串,但我真的不明白它的含义以及对构建的影响。

最佳答案

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.

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

注意:这与方法引用的数量没有任何关系,所以当你的 dex 文件有超过 64k 的方法时,这种模式无法解决。

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

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

关于android - 用于 Gradle 构建的 dexOptions 中的 jumboMode 的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32067223/

相关文章:

android - 如何在 Android 中设置 SocketIO 的传输?

java - Android:应用程序在上传图片时在设备上崩溃,java.lang.outofMemoryError

android - 我需要添加什么依赖项才能使用 com.google.android.material.slider.Slider

java - 为什么我不能在查询 Firestore 中使用 whereEqualTo 条件

bash - Gradle 无法识别我设置的 JAVA_HOME

android - Gradle 构建无法从自定义 Maven 存储库获取依赖项

android - 将音频从 IP 摄像机流式传输到 android (audiostream.cgi)

java - 在为图像集成 firebase 数据引用时,我遇到了下面提到的错误

java - 如何使用 gradle 创建的 fatJar 中存在的主要方法执行类

android-studio - Android Studio说失败:更新至3.6.2后,构建失败,并出现异常