Android Build: Dex Jumbo Mode in Gradle

AndroidAndroid Build

Android Problem Overview


I am using following line in android ant build (project.properties):

dex.force.jumbo=true

Now we are migrating from ant to Gradle. Is it possible to get jumbo mode active in Android Gradle build?

Android Solutions


Solution 1 - Android

You can modify your build.gradle file to include:

android {
  	dexOptions {
        jumboMode = true
    }
}

Please note that this option is only supported by the now deprecated DX compiler. The D8 compiler does not support this option. From AGP 7.0 (released with Android Studio 2020.3.1 - Arctic Fox) DX support is removed completely.

Solution 2 - Android

Modify build.gradle in your module to add:

android {
    dexOptions {
        jumboMode = true
    }
}

After that run gradle clean in your project root

Solution 3 - Android

I'm not sure if it possbile to set force jumbo in Gradle, but since Android Studio 0.2.4 you can enable it in Compiler -> Android DX Compiler -> Force Jumbo Mode.

Solution 4 - Android

I was able to do this on Windows by changing the dx.bat in the build-tools and adding the --force-jumbo parameter as a default. Definitely a work around though - hopefully this will be addressed in the Gradle plugin.

Solution 5 - Android

Check your build tools. Update if necessary and try again.

Solution 6 - Android

> this error means that your method have got over 65536

just add multiDexEnabled on default config at build.gradle file

defaultConfig {
   ...
   multiDexEnabled true
   ... 
}

this way also work: https://blog.csdn.net/H_O_W_E/article/details/77742907

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionendianView Question on Stackoverflow
Solution 1 - AndroidIsrael VareaView Answer on Stackoverflow
Solution 2 - Androidnlmm01View Answer on Stackoverflow
Solution 3 - AndroidsealskejView Answer on Stackoverflow
Solution 4 - AndroidNick CaballeroView Answer on Stackoverflow
Solution 5 - AndroidstdoutView Answer on Stackoverflow
Solution 6 - AndroidLouisView Answer on Stackoverflow