Com.android.dex.DexIndexOverflowException: method identifier not in [0, 0xffff]: 65536 in android studio

I have an android project. When I import it into an eclipse. It works great. But when I imported it into Android studio, he gave: -

com.android.dex.DexIndexOverflowException: method identifier not in [0, 0xffff]: 65536

Error

when building. It is even possible that the project behaves differently in eclipse and Android Studio. In both cases (Yes / No), how to solve this?

I checked the build.gradle file for dependencies. All dependencies are similar to what I use in eclipse.

+5
source share
3 answers

Android has a predefined upper limit of methods 65536 .

The most common reason for this is the use of a complete library of Google Play services, and not just the subset you need, such as design, maps, maps, etc.

If this is not the case, use the multidex library, which gives a larger limit. Take a look here: http://developer.android.com/tools/support-library/features.html#multidex

Basically this is only in gradle:

 com.android.support:multidex:1.0.0 
+6
source

For ANDROID STUDIO ... Enable Instant Launch

In File-> Preferences-> Build, Execution, Deployment-> Instant Run-> Check Enable Instant run for hot swapping ...

Hope this helps

+9
source

My problem was resolved by adding "multiDexEnabled true" as shown in the build.gradle module.

 android { ... defaultConfig { ... multiDexEnabled true 

Update

Using the code above, I was able to create and run on debugging devices (below the version of "marshmallow"), but on "marshmallow" devices I found the following error.

: 6: error: android.support.multidex package does not exist. import android.support.multidex.MultiDexApplication;

To solve the problem, I have to use the following command in the build.gradle module of the project.

compile 'com.android.support:multidex:1.0.1'

+3
source

All Articles