如何在Gradle中找到依赖冲突

时间:2014-10-21 14:57:04

标签: android gradle dependencies dependency-management

我试图在我的项目中添加nineoldandroid lib,但我无法找到我的依赖问题发生的位置。 我的依赖项:

dependencies {
   compile files('src/main/libs/guice-3.0-no_aop.jar')
   compile files('src/main/libs/javax.inject-1.jar')
   compile files('src/main/libs/roboguice-2.0.jar')
   compile files('src/main/libs/junit-4.11.jar')
   compile files('src/main/libs/hamcrest-core-1.3.jar')
   compile 'com.squareup:otto:1.3.5'
   compile 'com.google.android.gms:play-services:6.1.11'
   compile 'com.android.support:support-annotations:20.0.0'
   compile 'com.android.support:appcompat-v7:21.0.0'
   compile 'com.android.support:support-v4:21.0.0'
   compile 'com.google.code.findbugs:jsr305:1.3.9'
   compile 'io.nlopez.smartlocation:library:2.0.7'
   compile ('com.nineoldandroids:library:2.4.0'){
      exclude module: 'appcompat-v7'
      exclude module: 'support-v4'
      exclude module: 'support-annotations'
      exclude group: 'com.google.android'
      exclude group: 'com.google.android.*'
      exclude group: 'com.google.code.findbugs'
      exclude group: 'com.android.dx'
   }
   //compile project(':android-spinwheel')
}

我得到错误:

Error:Execution failed for task ':app:dexDebug'.
    > com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /home/usr/soft/android-studio/sdk/build-tools/21.0.1/dx --dex --num-threads=4 --output /home/usr/vc/android-local/app/build/intermediates/dex/debug /home/usr/vc/android-local/app/build/intermediates/classes/debug /home/usr/vc/android-local/app/build/intermediates/dependency-cache/debug /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/internal_impl-21.0.0-d8c58b966f1337ac583be7169abe38eafaaea523.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/hamcrest-core-1.3-42a42e6ec38e3a6ec6a99347d11a9296a04eca00.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/classes-3528df59bfffc0f1961007c5282087aa82de987f.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/guice-3.0-no_aop-91a65442530b2d5fb3bf96359d70d249985649f6.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/otto-1.3.5-c4d763fed0f5fe8a97ac31f49ba37d2cd1567ad8.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/classes-8250441981c0a4195e9e6068c3efdb149c0dedfd.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/classes-f112c8b8d83a64a7f22e07537d04c10f33f5ab35.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/jsr305-1.3.9-4b2d061766ae6ca309e240b50953cd2ffef968a0.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/roboguice-2.0-6654a0e822af0f9305ce06f00f0d4e61dfab50fd.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/classes-ae9e0725b0368edcf3df124ccecd0b5e1ad65358.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/javax.inject-1-f4b5053b6356ac4792c8e5f52c58c62ca27a07cb.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/junit-4.11-2882cc48337848b98707492071ee6cb29be1a828.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/library-2.4.0-75e51598c065016181fac0cecd368e796b5769a8.jar /home/usr/vc/android-local/app/build/intermediates/pre-dexed/debug/support-annotations-21.0.0-ecd4ef2c68ca29b6a76021f4c9ef5fc3656e79db.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define    Lcom/nineoldandroids/animation/Animator$AnimatorListener;
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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)

正如你所看到的,我已经尝试了我能想到的每一个排除,我希望我能以正确的方式使用它。

2 个答案:

答案 0 :(得分:1)

我遇到了类似的问题,但使用了Otto库。我的问题是我的libs文件夹中有一个jar,我从maven repository添加了同一个库的另一个版本(分支)。如果我删除其中一个,这个问题就解决了,但我需要它们。那是因为我想使用AndroidAnnotations

但是我无法弄明白我该怎么做。

  

从我所看到的问题回到你的问题,你可以这样解决:

您必须找到您添加的哪个库与nineoldandroids库存在依赖冲突。您必须逐个删除它们并找到它们中的哪一个。在您发现尝试解决这两个库之间的冲突之后。

我希望这会对你有所帮助。

答案 1 :(得分:1)

您正在使用的SpinnerWheel库有一个过时版本的nineoldandroids作为jar添加。您将需要删除它并添加更新的gradle依赖项或将jar更新为您在主gradle文件中指定的版本。

在最近的一篇文章中(截至本文撰写时),我正在做同样的事情,遇到同样的问题。需要一段时间才能找到,因为Android Studio隐藏了libs目录,因此我不得不导航到该文件夹​​以删除jar。

如果你不再使用SpinnerWheel库,那么你的其他一个依赖项就会发生同样的事情。