Problem:
[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
[dx] java.nio.BufferOverflowException
[dx] at java.nio.Buffer.nextPutIndex(Buffer.java:519)
[dx] at java.nio.HeapByteBuffer.putShort(HeapByteBuffer.java:315)
[dx] at com.android.dex.Dex$Section.writeShort(Dex.java:818)
[dx] at com.android.dex.Dex$Section.writeTypeList(Dex.java:870)
[dx] at com.android.dx.merge.DexMerger$3.write(DexMerger.java:437)
[dx] at com.android.dx.merge.DexMerger$3.write(DexMerger.java:423)
[dx] at com.android.dx.merge.DexMerger$IdMerger.mergeUnsorted(DexMerger.java:317)
[dx] at com.android.dx.merge.DexMerger.mergeTypeLists(DexMerger.java:423)
[dx] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:163)
[dx] at com.android.dx.merge.DexMerger.merge(DexMerger.java:187)
[dx] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
[dx] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:230)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:199)
[dx] at com.android.dx.command.Main.main(Main.java:103)
Using Android Build Tools 19
Solution:
This issue has been reported to Android here.
1. Some have had success by adding the android-support-v4.jar to your libs directory. (However, did not.)
2. Delete the Adnroid SKD Build-Tools 19, and revert back to 18.1.1
- Open Android SDK Manager
- [x] Select Android SDK Build-Tools 19
- Select button Delete 1 Package...
* Don't forget to delete the android-support-v4.jar file if you added this to your libs directory.
Resources:
http://stackoverflow.com/questions/19727915/android-dex-gives-a-bufferoverflowexception
https://code.google.com/p/android/issues/detail?id=61710