-2

I have a project in Android Studio that was previously exported successfully. However, I updated the IDE and now I am getting this error:

Error:Execution failed for task ':android:dexRelease'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\Ajay\Downloads\android-sdk_r24.4.1-windows\android-sdk-windows\build-tools\21.0.0\dx.bat -JXmx4g --dex --force-jumbo --output C:\Users\Ajay\Downloads\jetpack(1)\JetPack\game\android\build\intermediates\dex\release --input-list=C:\Users\Ajay\Downloads\jetpack(1)\JetPack\game\android\build\intermediates\tmp\dex\release\inputList.txt Error Code: 2 Output: 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:502) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302) at com.android.dx.command.dexer.Main.run(Main.java:245) at com.android.dx.command.dexer.Main.main(Main.java:214) at com.android.dx.command.Main.main(Main.java:106)

Previously, I had errors with Google Play services. So I had edited my .build file to :

dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.android.gms:play-services:7.8.0'

Where as before the .build file was as follows:

dependencies {
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.google.android.gms:play-services:+'

I did not need to edit my .build files before the update, so I'm not sure what the issue is. Any ideas?

  • 2
    Maybe some minutes searching would help... [dexindexoverflowexception-issue-after-updating](http://stackoverflow.com/questions/26515378/dexindexoverflowexception-issue-after-updating-to-latest-appcompat-and-support-l) – JoGe Dec 01 '15 at 07:29

2 Answers2

0

I think the problem is related to your obfuscating tool Dexguard. Try removing it and build again. I am not familiar with Dexguard but in Proguard you keep the needed class using -keep if those classes are removed while building.

rockfight
  • 1,916
  • 2
  • 20
  • 31
0

The problem is you are implementing huge sized libraries and your dex file is over sized.

compile 'com.google.android.gms:play-services:7.8.0'

You dont need to implement whole service. You should divide them.

compile 'com.google.android.gms:play-services-wearable:8.3.0'

More docs from here.

By doing this, your decreasing projects method. So dex file will be down sized too. If your problem exists, then you need to split your dex files by implementing Multidex

Good luck there.

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30