首页 > 代码库 > Android 多个DEX错误 Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;

Android 多个DEX错误 Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;

今天在写程序的时候我的Android Studio 突然编译错误(错误提示如下:)后来经过我的几番折腾发现每一次都要先Clear Project一下然后再Build就可以了,如果你第二次再Build的时候就报错。后来我就找到了最强的老师(Google)尝试解决!可惜很遗憾,我在Google上看到的都是Eclipse上的解决方法。并没有找到我想要的答案,难道要我每一次在Build的时候都要先Clear Project吗?最后又经过我的几番折腾我发现在Project Structure--->app--->Properties中有一个选项叫:Incremental Dex (增加的DEX)的值为True,我又新建了一个项目发现默认值是空值,果然把这个改成空值问题就全然解决了!虽然现在我也不知道这一个选项到底是有什么用。

错误提示:

 

Information:Gradle tasks [:app:assembleDebug]:app:preBuild UP-TO-DATE:app:preDebugBuild UP-TO-DATE:app:checkDebugManifest:app:preReleaseBuild UP-TO-DATE:app:prepareComAndroidSupportAnimatedVectorDrawable2330Library UP-TO-DATE:app:prepareComAndroidSupportAppcompatV72330Library UP-TO-DATE:app:prepareComAndroidSupportSupportV42330Library UP-TO-DATE:app:prepareComAndroidSupportSupportVectorDrawable2330Library UP-TO-DATE:app:prepareDebugDependencies:app:compileDebugAidl UP-TO-DATE:app:compileDebugRenderscript UP-TO-DATE:app:generateDebugBuildConfig UP-TO-DATE:app:generateDebugAssets UP-TO-DATE:app:mergeDebugAssets UP-TO-DATE:app:generateDebugResValues UP-TO-DATE:app:generateDebugResources UP-TO-DATE:app:mergeDebugResources UP-TO-DATE:app:processDebugManifest UP-TO-DATE:app:processDebugResources UP-TO-DATE:app:generateDebugSources UP-TO-DATE:app:processDebugJavaRes UP-TO-DATE:app:compileDebugJavaWithJavac:app:compileDebugNdk UP-TO-DATE:app:compileDebugSources:app:preDexDebug UP-TO-DATE:app:dexDebugUNEXPECTED TOP-LEVEL EXCEPTION:com.android.dex.DexException: Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:591)    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:546)    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:528)    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)    at com.android.dx.command.dexer.Main.run(Main.java:277)    at com.android.dx.command.dexer.Main.main(Main.java:245)    at com.android.dx.command.Main.main(Main.java:106)Error:Execution failed for task :app:dexDebug.> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process command C:\Program Files\Java\jdk1.8.0_73\bin\java.exe‘‘ finished with non-zero exit value 2

 

解决方法:

技术分享

 

Android 多个DEX错误 Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;