2

I am not able to build my Android app. I keep seeing this error:

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106)

However, it doesn't tell me which gradle dependencies are causing my build to fail. How do I go about troubleshooting this?

Igor

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
  • Possible duplicate of [Unable to execute dex: method ID not in \[0, 0xffff\]: 65536](http://stackoverflow.com/questions/15209831/unable-to-execute-dex-method-id-not-in-0-0xffff-65536) – Paul Mar 30 '16 at 19:59
  • @Paul Is that still the best solution in 2016? – IgorGanapolsky Mar 30 '16 at 20:01
  • Possible duplicate of [How to enable multidexing with the new Android Multidex support library](http://stackoverflow.com/questions/26609734/how-to-enable-multidexing-with-the-new-android-multidex-support-library) – mbmc Mar 30 '16 at 20:01
  • @mbmc How is that a duplicate? – IgorGanapolsky Mar 30 '16 at 20:03
  • You reached the limit: http://developer.android.com/tools/building/multidex.html, gotta enable multidex. – mbmc Mar 30 '16 at 20:04
  • 1
    If you don't want to enable multidex, then read the link I've posted to avoid reaching the limit. – mbmc Mar 30 '16 at 20:24

1 Answers1

4

It seems the only way to solve my dilemma was to enable multidex in my project:

  1. In AndroidManifest.xml:

<application android:name="android.support.multidex.MultiDexApplication"

  1. In app's build.gradle:

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

defaultConfig {
     testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
     multiDexEnabled true
IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147