Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio DexIndexOverflowException: method ID not in

I use Android Studio to develop an application and I face this error which I have no idea how to solve.

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

:app:lintVitalRelease
:app:prePackageMarkerForRelease
:app:transformClassesWithDexForRelease FAILED
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Information:BUILD FAILED
Information:Total time: 34.783 secs
Information:1 error 
like image 939
Hassan Ouhadou Avatar asked Aug 02 '16 07:08

Hassan Ouhadou


2 Answers

Try to enable multiDex in build.gradle:

android {

    defaultConfig {
        ...

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

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

This article may helpful: DexIndexOverflowException issue after updating to latest appcompat and support library

like image 92
Huy Avatar answered Oct 15 '22 15:10

Huy


Android has a pre-defined upper limit of Methods of 65536.

if you added play services as whole please remove it and add specific ones.

remove compile 'com.google.android.gms:play-services:9.6.1' and then add ex: compile 'com.google.android.gms:play-services-maps:9.6.1' for maps.

https://developers.google.com/android/guides/setup

shows a list of the separate APIs that you can include when compiling your app, and how to describe them in your build.gradle file

like image 27
vbp Avatar answered Oct 15 '22 15:10

vbp