2

I've developed an android application in Eclipse which uses lot of library JAR files so i got exception of

Unable to execute dex: method ID not in [0, 0xffff]: 65536

So i thought to implement multidex. I searched many blogs but nothing helps me in the eclipse framework. So i installed the Gradle plugin for eclipse to achive the multidex which was mentioned in many posts (As mentioned here, and Here). Both telling the same method to add

multiDexEnabled true

but its not working

I asked my application class to override

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

and in the gradle file which is builded i edited as

    android{
            defaultConfig {
                 minSdkVersion 14 //lower than 14 doesn't support multidex
                 targetSdkVersion 22

                 // Enabling multidex support.
                 multiDexEnabled true
             }
     }

But it doesn't helped me. Can anyone help me to find how to multidex my application with eclipse or correct way to multidex with the gradle.

Community
  • 1
  • 1
S A R
  • 146
  • 3
  • 20
  • possible duplicate of [Enabling MultiDex Support in Android to achieve 65K+ methods in Eclipse](http://stackoverflow.com/questions/27967191/enabling-multidex-support-in-android-to-achieve-65k-methods-in-eclipse) – Mariano Zorrilla Sep 10 '15 at 17:38
  • I've already posted one link which also says the same method to add multiDexEnabled true but it doen't do the multidexing and still i get the error of 65K methods in eclipse – S A R Sep 11 '15 at 06:23
  • having the same issue in Android Studio – Patrick Jackson May 24 '16 at 13:53

2 Answers2

0

add this to your gradle dependencies:

dependencies {
    compile 'com.android.support:multidex:1.0.0'
    ... 
}

If that doesn't work, I'm lost as to how to help you because that is the only thing missing that I can see from other answers here on SO.

Lucas Crawford
  • 3,078
  • 2
  • 14
  • 25
0

You need to do 3 things to enable MultiDex:

1) Add following dependency to your build.gradle file:

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

2) Enable multidex in your build.gradle file:

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}

3) Finally, if you are using a custom Application class, it should extend MultiDexApplication:

public class MuyApplication extends MultiDexApplication {

}

or if you are not using a custom Application class, do the following in your manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>
yrazlik
  • 10,411
  • 33
  • 99
  • 165
  • Hi, I added the depenencies in gradle file and enabled multidex then extended the application class as MultiDexApplication but still i'm getting the error – S A R Sep 11 '15 at 06:46
  • Error : Unable to execute dex: method ID not in [0, 0xffff]: 65536 Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536 – S A R Sep 11 '15 at 06:55
  • Have got solution @S A R – Narender Reddy Oct 13 '16 at 12:52