多个dex文件定义Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat [英] Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

查看:30
本文介绍了多个dex文件定义Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我从命令行运行 gradle assembleDebug,我突然收到这个错误:

If I run gradle assembleDebug from the command line, I am suddenly getting this error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
    at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:186)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300)
    at com.android.dx.command.dexer.Main.run(Main.java:232)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)

如果我 grep for v4,我会在构建文件夹中看到两个文件.

If I grep for v4 I see two files inside my build folder.

Binary file build/pre-dexed/debug/support-v4-19.0.0-2ba5fdd60a6c3836b3104a863fe42897da1fa9d1.jar matches
Binary file build/pre-dexed/debug/support-v4-r7-227d905d79b23b20866531d4f700446c040a2ccb.jar matches

我的 gradle 文件只包含这个支持库:

My gradle file includes only this support library:

compile 'com.android.support:support-v13:19.0.0'

我对如何以某种方式包含 r7 库感到困惑.我已经运行 gradle clean 并且当我重新运行 assembleDebug 时它总是出现在那里.

I am stumped as to how the r7 library is included somehow. I've run gradle clean and it always appears there when I rerun assembleDebug.

如果我在构建目录中 grep for r7,我会在文件中看到它:

If I grep for r7 inside the build directory, I see it inside the file:

Binary file build/exploded-bundles/ComGoogleAndroidGmsPlayServices4030.aar/classes.jar matches

如果我不包含 v13,那么其他东西就无法编译.

If I don't include v13, then other things don't compile.

但是 v13 不包括 v4 支持库吗?

But doesn't v13 include v4 support library?

这是播放服务 AAR 包和 v13 库之间的不兼容吗?

Is this an incompatibility between play services AAR bundle and the v13 library?

我从 gradleplease.appspot.com 获取了 gradle 文件.

I grabbed the gradle file from gradleplease.appspot.com.

移除播放服务并不能解决问题;同样的错误.

Removing play services does not fix it; same error.

我在 build.gradle 中的依赖项:

My dependencies inside build.gradle:

 dependencies {


 // Google Play Services
//compile 'com.google.android.gms:play-services:4.0.30'

// Support Libraries
//compile 'com.android.support:support-v4:19.0.0'
///compile 'com.android.support:appcompat-v7:19.0.0'
//compile 'com.android.support:gridlayout-v7:19.0.0'
compile 'com.android.support:support-v13:19.0.0'
compile 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
compile 'commons-codec:commons-codec:1.9'
compile 'com.madgag:markdownj-core:0.4.1'
compile 'com.wu-man:android-oauth-client:0.0.2'
compile 'com.google.http-client:google-http-client-jackson2:1.17.0-rc'
compile 'org.apache.commons:commons-lang3:3.2'
compile 'com.google.code.gson:gson:2.2.4'
}

推荐答案

Run gradle -q dependencies (或 gradle -q :projectName:依赖)生成依赖报告.您应该看到 r7 来自哪里,例如:

Run gradle -q dependencies (or gradle -q :projectName:dependencies) to generate a dependency report. You should see where r7 is coming from, such as:

compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
|    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
|    |    --- com.google.android:support-v4:r7
|    +--- com.commonsware.cwac:camera:0.5.4
|    --- com.android.support:support-v4:18.0.+ -> 18.0.0
--- com.android.support:support-v4:18.0.+ -> 18.0.0

然后,使用 exclude 指令来阻止该依赖项.就我而言,它来自我的 CWAC-Camera 库,所以我使用:

Then, use the exclude directive to block that dependency. In my case, it is coming from my CWAC-Camera library, and so I use:

dependencies {
    compile('com.commonsware.cwac:camera-v9:0.5.4') {
      exclude module: 'support-v4'
    }

    compile 'com.android.support:support-v4:18.0.+'
}

(其中第二个 compile 语句表示您实际想要的版本)

(where the second compile statement indicates what version you actually want)

这应该会解决问题,因为您将看到是否再次运行依赖关系报告:

That should clear matters up, as you will see if you run the dependency report again:

compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
|    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
|    --- com.commonsware.cwac:camera:0.5.4
--- com.android.support:support-v4:18.0.+ -> 18.0.0

这篇关于多个dex文件定义Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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