2017-07-15 75 views
0

我想在我的項目中添加一個依賴關係giphy4j,此依賴關係使用junit 4.8.1,但我的項目使用最新的junit 4.12衝突的依賴關係 - android studio

的build.gradle(模塊:APP):

androidTestCompile 'junit:junit:4.12' 
compile 'at.mukprojects:giphy4j:1.0.1' 

此配置是給我錯誤的gradle上同步。
當我將androidTestCompile更改爲compile時,反之亦然。我沒有明白這一點。我深入挖掘依賴的東西compile,apk, TestCompile等,但無法得到正確的想法。(因爲我是一名新生)。而且,這種相互矛盾的錯誤也是不容易理解的。

point 1:編譯junit(用apk發佈)錯了嗎?當我創建一個新項目時,默認設置爲junit 4.12

點2:我不想來配置與androidTestCompile我的第三方的依賴,原因是其不release configuration顯示當我運行./gradlew app:androiddependencies

./gradlew app:androiddependencies output

錯誤:錯誤:項目 ':應用程序':衝突與依賴「的JUnit JUnit的。應用程序(4.8.1)和測試應用程序(4.12)的已解決版本不同。詳情請參閱http://g.co/androidstudio/app-test-app-conflict

+0

爲什麼不從其他依賴項中排除junit? –

+0

所以gradle包含junit兩次? 我認爲庫取決於'junit 4.8.1'。但是我的項目使用'4.12'版本,因此它們是衝突的。 –

+0

這就是錯誤所說的,是的。但是,不清楚爲什麼你得到這個錯誤,除非你真的編譯測試依賴關係 –

回答

0

從庫中排除junit。

compile ("at.mukprojects:giphy4j:1.0.1") { 
    exclude group: 'junit', module: 'junit' 
} 
+0

,所以'giphy4j'然後會使用'junit 4.12'? –

+0

你試過了嗎?它不會強制giphy4j使用'junit 4.12'。它只是將該庫排除在您的應用程序模塊gradle中。 – Rahul

+0

這樣做會觸發錯誤。 '錯誤:(3,17)錯誤:package org.junit不存在'for ExampleUnitTest.java' –