gpt4 book ai didi

android - 如何修复android多个dex文件定义异常

转载 作者:太空狗 更新时间:2023-10-29 16:13:44 25 4
gpt4 key购买 nike

Android 4.2 ZBarCodescan java 应用程序需要在 Windows 7 x64 计算机上编译。

它的源代码是located here .

已安装 Android Studio,并使用 Github import 命令导入代码。在 gradle 文件中 API 更改为 23

compileSdkVersion 23 

根据

How to use eclipse project from github for Android development

Android studio Build APK 命令产生异常

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:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
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)

尝试通过添加行来解决此问题

dexOptions {
preDexLibraries = false
}

根据

到两个项目 gradle 行

Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

导致错误

Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanMr2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;

如何解决这个问题?

Answer here建议检查依赖树。如何在 Android Studio 中获取这棵树以及如何修复它?

移除android-support-v4.jar异常后

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:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
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)

仍然发生。

更新。我尝试使用 https://github.com/cricket007/DeviceSDK/tree/fixes 导入修复分支url 但测试按钮和导入产生错误

error

如何导入这个分支?

最佳答案

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

发生这种情况是因为您添加了两次相同的类。

在您的情况下,您正在使用:

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
}

appcompat-v7support-v4 有依赖关系。
您的 libs 文件夹中有 android-support-v4.jar

删除 android-support-v4.jar(你不需要它,因为 appcompat 已经有了)。

关于android - 如何修复android多个dex文件定义异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36103262/

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