当前位置: 首页 > 面试题库 >

Android构建故障转移com.android.dex.DexException:多个dex文件定义了Landroid / support

符鸣
2023-03-14
问题内容

在Android项目中,团队主要还是使用Eclipse并添加了一些第3方库,然后在运行gradle build时Android
Studio无法在设备anf上运行,并出现错误:

: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.

warning: Ignoring InnerClasses attribute对于不同的文件,以此类推10到20次

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.+’

Eclipse ADT没有问题。 如何使用Gradle / Android Studio克服?


问题答案:

感谢Guillermo Merino的提示。是的,android-support-v4.jar那里。

解决exclude

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


 类似资料:
  • 问题内容: 我正在尝试将Espresso 2添加到我的项目中(该项目还具有许多其他依赖项),但是在尝试运行测试时遇到了此错误: 非测试版本工作正常。 有人有调试最佳方法的任何技巧吗? 我尝试运行,但是看不到任何明显的问题(尽管我对解释其输出了解不多): 我也尝试搜索目录的子文件夹,但看不到任何冒烟者(尽管我不确定我是否以正确的方式搜索了所有外部依赖项JAR)。 这是我的build.gradle的依

  • 我无法编译该项目,编译时出现以下错误: 错误:任务': myApp: dexDebug'执行失败。 通用域名格式。Android石斑鱼类。常见的内部的LoggedErrorException:无法运行命令:C:\Program Files(x86)\Android\Android studio\sdk\build tools\21.0.2\dx。bat--dex--输出C:\Users\Andro

  • 当我将android支持注释添加到我的依赖项时 我有一个错误: 错误代码:2输出:意外的顶级异常:com.android.dex.dexException:多个dex文件定义Landroid/Support/Annotation/Animres;在com.android.dx.merge.dexmerger.readsortabletypes(dexmerger.java:594)在com.and

  • 如果我grep v4,我会在构建文件夹中看到两个文件。 我的gradle文件只包括以下支持库: 我很难理解r7库是如何被包括在内的。我运行了,当我重新运行AssembleDebug时,它总是出现在那里。 这是play services AAR bundle和v13库之间的不兼容吗?

  • 错误:将字节码转换为dex时出错:原因:com.android.dex。DexException:多个dex文件定义Landroid/arch/lifecycle/LiveData$LifecycleBoundObserver; 我的 gradle 文件 **这就是错误,我明白了**

  • 我可以 ,它只有一个: <代码>设置。gradle如下: @garbriele:我更新了新问题,显示项目的