我以前见过各种版本的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
我有一个项目需要使用Google Play服务库.但是当我将它添加到我的依赖项时,我收到以下错误:
意外的顶级例外
错误:任务':app:dexDebug'的执行失败.com.android.ide.common.internal.LoggedErrorException:无法运行命令:C:\ Eclipse\adt-bundle-windows-x86_64-20140702\sdk\build-tools\21.1.2\dx.bat --dex - no-optimize --output C:\ Users\Reigstad\Documents\secret-tyrion-android\Tyrion\app\build\intermediates\dex\debug --input-list = C:\ Users\Reigstad\Documents\secret-tyrion -android\Tyrion\app\build\intermediates\tmp\dex\debug\inputList.txt错误代码:2输出:UNEXPECTED TOP-LEVEL EXCEPTION:com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中: 65536 at com.android.dx.merge.DexMerger $ 6.updateIndex(DexMerger.java:502)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)位于com.android.dx.command.dexer.Main.runMonoDex(Main.java:30)3)com.android.dx.com上的com.android.dx.command.dexer.Main.run(Main.java:246)com.android.dx.com(Main.java:215) .command.Main.main(Main.java:106)>
我的build.gradle看起来像这样:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'org.immutables:gson:1.1.3'
compile 'org.parceler:parceler:0.2.15'
compile 'com.google.android.gms:play-services:6.5.87'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.tyrion.tyrion"
minSdkVersion 13
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false …Run Code Online (Sandbox Code Playgroud)