Application too big? Unable to execute dex: Cannot merge new index into a non-jumbo instruction

rupps picture rupps · May 7, 2014 · Viewed 22.2k times · Source

I am getting the following error when I compile my app:

[2014-05-07 21:48:42 - Dex Loader] Unable to execute dex: Cannot merge new index 65536 into a non-jumbo instruction!

I am at the point that if I declare a new method anywhere in my package, I get this error. If I don't, the app compiles.

I would like to know what exactly (and accurately) does this error mean. My app is big, but I don't think its that big! So:

  • Does the error mean I have too many methods? public? static? package? members?
  • Is it related to the methods/members of my root package, or also to the included JAR libraries?
  • Is there a way to get more debug information about this?

I already know about that "jumbo" enabling flag addressed in the similar questions here in SO, however, I think jumbo mode is not available on the API level I'm targeting (ICS).

Answer

fpanizza picture fpanizza · May 7, 2014

Your error is for the amount of strings (methods, members, etc) in a single dex file.

You need to compile you app using jumbo in dex with:

dex.force.jumbo=true

in project.properties

This increment the limit for strings in a dex files. And your project will probably compile.

Also with jumbo set, the is another limit of 64K only for methods in an single dex. If you get this limit in the future , you will need to remove some dependencies.

UPDATE: for build with Gradle: In Gradle you can enable jumboMode also in the build.gradle file with:

dexOptions {
    jumboMode = true
}

Check: Android Build: Dex Jumbo Mode in Gradle

Also with Gradle you can avoid the 64K limit for methods using multidex build, tutorial here: https://developer.android.com/tools/building/multidex.html