多个dex文件在android studio中定义了Landroid/support/

时间:2023-02-11
本文介绍了多个dex文件在android studio中定义了Landroid/support/v4/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以与许多库集成(添加和工作).

但是对于 ActionBarSherlock 库,我有很多问题.

But as for ActionBarSherlock library, I have so many problems with it.

First Issue是热门issue多个dex文件定义

我知道 duplicated android-support-v4.jar 导致它,但我现在无法解决这个问题:

I know The duplicated android-support-v4.jar causes it, but I can not solve this issue now :

Error:Execution failed for task ':fitness:dexDebug'.

Error Code:
2
Output:
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:594)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

我遵循了 同样的错误中的答案.它使用了:

I followed the answer in same error. It used :

dependencies {
    compile('...') {
      exclude module: 'support-v4'
    }

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

但我收到了第二个问题:unsupported Gradle DSL method found: 'exclude()'! 错误.因此,我像这样更改了 main modulebuild.gradle:

But I received Second Issue : unsupported Gradle DSL method found: 'exclude()'! error. Therefore I changed build.gradle of main module like this:

//configurations {
//    all*.exclude group: 'com.android.support', module: 'support-v4'
/