Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DexException: Cannot merge new index 65536 into a non-jumbo instruction

For some unknown reason my app suddenly won't build from Android Studio.

I'm keep getting

> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /home/martynas/android-sdk/build-tools/19.1.0/dx --dex --num-threads=4 --output
...
...
...
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Cannot merge new index 65536 into a non-jumbo instruction!

While the same application is built successfully from command line. I've checked method references count and it's way below the dreaded 64k.

I'm using AS 0.8.11 now.

like image 352
Martynas Jurkus Avatar asked Sep 29 '14 06:09

Martynas Jurkus


2 Answers

Set the jumboMode property in build.gradle:

android {
    ...
    dexOptions {
        jumboMode true
    }

}

I also found this useful: Showing dex method count by package.

like image 144
lydia_schiff Avatar answered Nov 07 '22 18:11

lydia_schiff


Try to add this line on your project.properties

dex.force.jumbo=true

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

Note : 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 - Google Play Services 6.5 (12-08-14)

With version 6.5 Google finally unbundled the Google Play Services. So from now on it'll be possible to selectively compile the APIs into your executable.

Example :

compile 'com.google.android.gms:play-services-maps:6.5.+'
compile 'com.google.android.gms:play-services-ads:6.5.+'

For all the other individual Google Play Services APIs check this page on d.android.com.

Update (21-04-2015) : https://developer.android.com/tools/building/multidex.html

like image 37
Haresh Chhelana Avatar answered Nov 07 '22 18:11

Haresh Chhelana