gpt4 book ai didi

java - Android 构建失败 com.android.dex.DexException : Multiple dex files define Landroid/support

转载 作者:行者123 更新时间:2023-11-30 11:07:14 25 4
gpt4 key购买 nike

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

: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 to 20 times for different files

(更新这些警告似乎是较旧的问题,请参阅 Dx warning issues with latest Android SDK 日期为 2011 年 11 月 2 日;也在 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.+'

Eclipse ADT没有问题。如何用gradle/Android Studio攻克?

最佳答案

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

通过 exclude as 解决

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

另见

关于java - Android 构建失败 com.android.dex.DexException : Multiple dex files define Landroid/support,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29003114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com