0

I'm facing a problem with adding the itextg-5.5.4.jar to my Android project in Android Studio. I copied the jar file to my libs folder and added it as a library.

I can use the classes in my project but when i try to start the app on my device, a UNEXPECTED TOP-LEVEL EXCEPTION occurs.

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/Paule/Documents/Android SDK/sdk/build-tools/android-4.4W/dx --dex --output Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) at com.android.dx.command.dexer.Main.run(Main.java:230) at com.android.dx.command.dexer.Main.main(Main.java:199) at com.android.dx.command.Main.main(Main.java:103)

build.gradle contains the dependencies (there are 14 more jar dependencies, I've removed them for a better overview)

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.android.gms:play-services-base:6.5.87'
compile files('src/main/libs/itextg-5.5.4.jar')
....
....
}

Does anyone know how to fix that error?

pawlinsky
  • 420
  • 1
  • 6
  • 18
  • Have you checked this ? http://stackoverflow.com/questions/21102598/android-studio-unexpected-top-level-exception Similar kind of issue. – Ganesh AB Feb 23 '15 at 11:16
  • please add your gradle.build file so that i can help you – Shreyash Mahajan Feb 23 '15 at 11:19
  • I've added build.gradle @Android007 i saw that too. But this is another exception, I'm not sure if it will help me with my problem – pawlinsky Feb 23 '15 at 11:53
  • check this out http://stackoverflow.com/questions/16608135/android-studio-add-jar-as-library – karan Feb 23 '15 at 11:59
  • do you really need last line of dependancies , because first line will do it for you. – MohK Feb 23 '15 at 12:02
  • @KaranMer thx for the link. I've followed the steps there. I copied it into libs folder ->right click on .jar -> add as library. I've even cleaned the project with gradlew clean...the error still appears :( – pawlinsky Feb 23 '15 at 12:53
  • @MohammadKhatri yes I have to add it, otherwise the classes aren't recognized in my project – pawlinsky Feb 23 '15 at 12:53

0 Answers0