我嘗試編譯模塊,其依賴關係樹看起來像Gradle的衝突解決方案不適用於Android項目?
+--- com.squareup.burst:burst-junit4:1.0.2
| +--- com.squareup.burst:burst:1.0.2
| \--- junit:junit:4.11 -> 4.12
| \--- org.hamcrest:hamcrest-core:1.3
+--- com.android.support.test.espresso:espresso-core:2.0
| +--- com.squareup:javawriter:2.1.1
| +--- org.hamcrest:hamcrest-integration:1.1
| | \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
| +--- org.hamcrest:hamcrest-library:1.1
| | \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
| +--- com.android.support.test.espresso:espresso-idling-resource:2.0
| +--- com.android.support.test:testing-support-lib:0.1
| | \--- junit:junit-dep:4.10
| | \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
| +--- com.google.code.findbugs:jsr305:2.0.1
| +--- javax.annotation:javax.annotation-api:1.2
| \--- org.hamcrest:hamcrest-core:1.1 -> 1.3
...
正如你可以看到有一個hamcrest-core
版本衝突,但gradle這個似乎認識到衝突並應用其默認「最新版本」戰略,正是我想要的。
然而,當嘗試(手動或通過Android Studio中)我得到
com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/MatcherAssert;
一些回答類似的問題建議exclude
荷蘭國際集團的不必要的罐子運行assembleDebugTest
,但我遇到了一堆類似的衝突,而且它變得有點失控。
爲什麼Gradle的默認衝突策略會自動刪除舊的jar? Android gradle插件是否抑制該功能?
http://stackoverflow.com/questions/20989317/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility – 2015-01-21 01:45:34
我確實看到了這一點,並且我理解了快速修復。我的問題是爲什麼Gradle的默認解析策略不能用於自動移除其中一個罐子,正如我期望閱讀[本文檔](http://www.gradle.org/docs/current/dsl/org)。 gradle.api.artifacts.ResolutionStrategy.html)。 – 2015-01-21 01:58:16
可以嘗試使用-verbose構建...找到configurations.resolutionStrategy {}被調用的位置....如果未被調用,則提供您自己的實現。 – 2015-01-21 16:04:56