Fix error “The number of method references in a .dex file cannot exceed 64K” in Android

Android application is compiled into Dalvik Executables or DEX files. By default an application can be compiled into a single DEX. A DEX file can contain a maximum of 65,536 methods. This exception is thrown when our application along with any external libraries has more than 65,536 or 64k methods.

To avoid this exception we have two options

Option 1 : Try to avoid any third party library if its not too important and you can manage it with inbuilt Android SDK tools and also remove any unused codes. Also configure ProGuard in your application with shrinking enabled to remove unused code.

Option 2: Configure multidex support in your app so that your app can be compiled into multiple DEX files.

Open build.gradle and write following in defaultConfig and dependencies section

defaultConfig {
multiDexEnabled = true

dependencies {
compile ''

Also, need to add following in the AndroidManifiest.xml in application section

<application ... android:name="">

Sample files

Further readings

Leave a Reply

Your email address will not be published. Required fields are marked *