Home » Android » android – What are the pros and cons for jumboMode (dexOptions)

android – What are the pros and cons for jumboMode (dexOptions)

Posted by: admin May 14, 2020 Leave a comment

Questions:

My Android build ~~is~~ was quite slow. 3-5 Minutes.

I removed a lot of dependencies and am now able to build without multidex – yay.

Nevertheless I ask myself if setting jumbo mode manually makes any sense…

jumboMode

when enabled it allows a larger number of strings in the dex files https://stackoverflow.com/a/24224385/570168

  • does jumbo mode has disadavantes?
  • should it be always on? (or better off)
  • does it have an effect on build speed at all?
How to&Answers:

Q1: Jumbo Mode doesn’t have any disadvantages rather it has some advatages.

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.

Q2: It depends on your class files. You can turn it on always if you don’t want to worry about it.

Q3: Solely It has not effect on build speed.