我正在使用 itextpdf-5.5.3.jar 为我在android studio中的应用程序进行pdf转换,但是我收到了以下错误:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\Android\Android Studio\sdk\build-tools\21.1.1\dx.bat --dex --output E:\Android\Workspace_ReceiptORG\ExpenseManager\app\build\intermediates\dex\debug --input-list=E:\Android\Workspace_ReceiptORG\ExpenseManager\app\build\intermediates\tmp\dex\debug\libraryList.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)
请帮帮我.........
答案 0 :(得分:1)
尝试启用multidex build.gradle:
android {
defaultConfig {
...
multiDexEnabled = true
}
}
参考:Unable to execute dex: method ID not in [0, 0xffff]: 65536
答案 1 :(得分:0)
您必须使用Android版iTextPDF。
下载" itextg-5.4.3.jar"
答案 2 :(得分:0)
对于意想不到的顶级例外:
app gradle:
defaultConfig {
multiDexEnabled true
}
外部标签:
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
如果仍然是错误,则可以增加堆大小。
android.dexOptions {
javaMaxHeapSize "4g"
preDexLibraries false
}