我以前见过各种版本的dex erros,但这个版本是新的.清理/重启等无济于事.图书馆项目似乎完好无损,依赖似乎正确联系在一起.
Unable to execute dex: method ID not in [0, 0xffff]: 65536
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
Run Code Online (Sandbox Code Playgroud)
要么
Cannot merge new index 65950 into a non-jumbo instruction
Run Code Online (Sandbox Code Playgroud)
要么
java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Run Code Online (Sandbox Code Playgroud)
tl;博士:Google的官方解决方案终于来了!
http://developer.android.com/tools/building/multidex.html
只有一个小提示,你可能需要这样做以防止在执行dex-ing时内存不足.
dexOptions {
javaMaxHeapSize "4g"
}
Run Code Online (Sandbox Code Playgroud)
还有一种巨型模式可以以不太可靠的方式解决这个问题:
dexOptions {
jumboMode true
}
Run Code Online (Sandbox Code Playgroud)
更新:如果您的应用程序很胖并且您的主应用程序中有太多方法,则可能需要按照应用程序重新设置应用程序
http://blog.osom.info/2014/12/too-many-methods-in-main-dex.html
我通过以下设置使用gradle:
compileSdkVersion 21
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.0.2
ANDROID_BUILD_SDK_VERSION=21
Run Code Online (Sandbox Code Playgroud)
我的gradle文件中还有以下设置:
compile 'com.android.support:support-annotations:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
Run Code Online (Sandbox Code Playgroud)
我总是得到错误UNEXPECTED TOP LEVEL EXCEPTION.
但是,当我做21.0.0给20.0.0它工作正常...但我不能够访问任何的Android API的21个选项.我在这里做错了吗?如何在没有此异常的情况下编译它?我没有其他等级项目以外的其他地方的支持罐(facebook等).
这是完整的堆栈跟踪:
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:283)
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)
Run Code Online (Sandbox Code Playgroud) android gradle android-support-library build.gradle android-5.0-lollipop