Android的构建失败了com.android.dex.DexException:多DEX文件定义Landroid /支持 [英] Android build fails over com.android.dex.DexException: Multiple dex files define Landroid/support

查看:2257
本文介绍了Android的构建失败了com.android.dex.DexException:多DEX文件定义Landroid /支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android项目是团队主要还是使用了Eclipse中增加了一些第三方库,那么Android的Studio无法运行摇篮建设时,对设备ANF运行出现错误:

In Android project were team primarily still uses Eclipse were added some 3rd parties libs, then Android Studio fails to run on device anf when running gradle build there is error:

:preDexDebug                      
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.umeng.socialize.bean.a) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.umeng.socialize.bean.b) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

和等警告:忽略InnerClasses属性 10〜20次为不同的文件

And so on warning: Ignoring InnerClasses attribute 10 to 20 times for different files

(更新这些警告似乎是较旧的问题,请参见霉素警告问题年11月2日'11最新的Andr​​oid SDK ; 也是在<一个href="http://stackoverflow.com/questions/27436463/many-issues-after-upgrading-to-android-studio-1-0">Many升级至Android工作室1.0 )

(UPDATE these warnings seem to be older issue, see Dx warning issues with latest Android SDK dated Nov 2 '11; also in Many issues after upgrading to Android Studio 1.0)

warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.tencent.mm.sdk.b.b) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

:dexDebug                    
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        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:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)

:dexDebug FAILED          

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_05\bin\java.exe'' finished with no
n-zero exit value 2

* Try:        
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED  

试着用

buildToolsVersion "19.1.0"
compileSdkVersion 19

buildToolsVersion "22"
compileSdkVersion 22

buildToolsVersion "21.1.2"
compileSdkVersion 21

compile 'com.android.support:appcompat-v7:19.0.+'

和     编译com.android.support:appcompat-v7:21.0 +

and compile 'com.android.support:appcompat-v7:21.0.+'

的Eclipse ADT有没有问题。如何克服摇篮/ Android的工作室?

推荐答案

感谢吉列尔莫·美利奴的提示。 是的,有是 Android的支持 - v4.jar 那里。

Thanks to Guillermo Merino for hint. Yes there is android-support-v4.jar there.

解决与排除

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar', exclude: 'android-support-*.jar')
    //...
}

又见

  • <一个href="http://stackoverflow.com/questions/27965690/gradle-exclude-or-add-reference-for-jar-file-hard-included-inside-library-classe">Gradle排除或添加的JAR文件参考硬包括库内classes.jar
  • <一个href="http://stackoverflow.com/questions/27855722/top-level-exception-appdexdebug-dex-no-optimize-output-android-studio">Top-Level例外的应用程序:dexDebug --dex - 无 - 优化 - 输出机器人工作室
  • <一个href="http://stackoverflow.com/questions/20989317/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility">Multiple DEX文件定义Landroid /支持/ V4 / accessibilityservice / AccessibilityServiceInfoCompat
  • Gradle Exclude or add reference for JAR file hard included inside library classes.jar
  • Top-Level Exception app:dexDebug --dex -no-optimize --output android studio
  • Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

这篇关于Android的构建失败了com.android.dex.DexException:多DEX文件定义Landroid /支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆