1

My project needs to have a bar chart and i have included the MPAndroid Chart library in my project. However, it is not successful and it gives the following message.

Unable to execute dex: Cannot merge new index 67075 into a non-jumbo instruction! Conversion to Dalvik format failed: Unable to execute dex: Cannot merge new index 67075 into a non-jumbo instruction!

I know the reason for this error as i have included other libraries in my project which exceeds the limit on Android. One of the alternatives is to use another library with less methods. However, if i want to use this library, are there any methods so that i would trim down the size of the library to meet my objective.

Antoine Murion
  • 773
  • 1
  • 14
  • 26

2 Answers2

1

Add dex.force.jumbo=true in the first line of project.properties

See here

I hope it helps you.

Community
  • 1
  • 1
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
0

You can enable Jumbo Mode in build.gradle. Change the following line and clean your project before sync gradle again.

android {
    dexOptions {
        jumboMode = true
    }
}

You can also enable Multi Dex

android {
    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 23
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

The difference between Jumbo Mode and Multi Dex as shown here is:

Jumbo Mode, when reading https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html, the const-string/jumbo is the jumbo mode for string. It is about the opcode such that "op vAA, string@BBBBBBBB" versus "op vAA, string@BBBB", 32 bits versus 16 bit.

Multi Dex is to allow to load classes from more than one dex file. The primary classes.dex must contain the classes necessary for calling this class methods. Secondary dex files found in the application apk will be added to the classloader after first call to MultiDex.install(Context) see https://developer.android.com/reference/android/support/multidex/MultiDex.html

Community
  • 1
  • 1
heloisasim
  • 4,956
  • 2
  • 27
  • 36