50

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?

endian
  • 4,761
  • 7
  • 32
  • 54
  • Move the setting to `gradle.properties` is ok, gradle.properties file is at the project path – Ninja Jul 26 '17 at 07:49

6 Answers6

140

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.

sgjesse
  • 3,793
  • 14
  • 17
Israel Varea
  • 2,600
  • 2
  • 17
  • 24
  • 4
    Had to **gradlew clean** before assembling. – ViliusK May 05 '15 at 09:18
  • Where is this build.gradle file? In the platform? What if I don't want to mess with the platform folder? – Francisco Souza Mar 17 '18 at 13:55
  • 1
    Although since AGP 7.0 the support for DX is removed, the 'jumboMode' property in the 'dexOption' remains available, but has no effect. The d8 compiler uses jumbo instructions on demand (if you have too many strings). Since it's not documented anywhere, this answer on google issuetracker seems to be the only reference mentioning that: https://issuetracker.google.com/issues/189354519 – Stanislav Shamilov Sep 22 '21 at 17:28
  • Great pointer @StanislavShamilov, thanks for this! It seems like we don't need to enable jumboMode anymore as the compiler will automatically handle large instructions – Guykun Jan 19 '22 at 16:32
4

Modify build.gradle in your module to add:

android {
    dexOptions {
        jumboMode = true
    }
}

After that run gradle clean in your project root

nlmm01
  • 871
  • 9
  • 12
0

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.

sealskej
  • 7,281
  • 12
  • 53
  • 64
0

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.

Nick Caballero
  • 944
  • 1
  • 8
  • 19
  • You can see the current source code for the Android builder here: https://android.googlesource.com/platform/tools/build/+/master/builder/src/main/java/com/android/builder/AndroidBuilder.java. The jumbo flag is simply not supported. If you have a better solution to enable it, please provide it instead of downvoting a working work-around. – Nick Caballero Oct 19 '13 at 15:44
  • Why do you say that the jumbo flag is not supported? In android source I see command.add("--force-jumbo"). – IgorGanapolsky Feb 10 '14 at 20:40
  • Ah you are right. I will update the answer with the correct configuration for Gradle. – Nick Caballero Feb 11 '14 at 15:28
-1

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

stdout
  • 2,471
  • 2
  • 31
  • 40
-1

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

Louis
  • 1
  • 1