2015-10-21 32 views
7

更新Findbugs插件至3.0.1版後,我無法在Android Studio中編譯多模塊項目。我還使用"com.google.code.findbugs:annotations:3.0.1"依賴關係來使用FindBugs註釋(例如@SuppressFBWarnings)。將FindBugs更新至3.0.1後編譯Android項目出錯

Execution failed for task ':presentation:packageAllDevelopDebugClassesForMultiDex'. 
> java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class 

我怎樣才能解決這個問題:

而組裝項目,我得到下面的錯誤?

+0

您可以使用此[腳本] (https://github.com/ethankhall/scripts/blob/master/gradle/find-file.gradle)來幫助查找CheckForNull的重複定義來自哪裏。用CheckForNull替換JsonIgnore。 – Ethan

回答

5

我解決了這個問題,原因是增加了"com.google.code.findbugs:annotations:3.0.1"附加依賴​​項('com.google.code.findbugs:jsr305:3.0.1''net.jcip:jcip-annotations:1.0')。爲了修復它,我們需要排除一些傳遞性依賴。

替換:

dependencies { 
    compile "com.google.code.findbugs:annotations:3.0.1" 
} 

dependencies { 
    compile ("com.google.code.findbugs:annotations:3.0.1") { 
     exclude module: 'jsr305' 
     exclude module: 'jcip-annotations' 
    } 
} 

dependencies { 
    compile ("com.google.code.findbugs:annotations:3.0.1") { 
     transitive = false 
    } 
} 
+1

我得到以上錯誤,但這個答案不能解決它:(無論是解決方案一,兩個,也沒有混合。即使使用'com.google.code.findbugs:註釋:2.0.3'給了我這個錯誤。我升級從Gradle 2.2.1到2.9,再回到2.3,這是AS 1.5的正確版本。所有添加一行FindBug Suppression :( – Giszmo

+1

我認爲你需要檢查與gradle任務「依賴關係」的依賴衝突,注意findbugs依賴關係樹 – ultraon

+1

找出它,因此對於「依賴關係樹」,你的意思是'../../gradlew -q dependencies'的輸出。在我們的例子中,我們不得不排除group:'com.google。 code.findbugs''在另一個依賴關係,拉着老版本的findbug – Giszmo

0

正如先前建議不包括模塊JSR305爲我工作,但我已經使用了不同的語法因導入一個項目,而不是一個模塊。

我進口存在我的硬盤上indipendent項目庫項目,所以我不得不

compile project(path: ':shareLib') 

要排除模塊JSR305我把我的代碼

compile (project(path: ':shareLib')) { 
    exclude module: 'jsr305' 
}