2017-04-05 108 views
0

我有一個android項目,有一個依賴於SDK的jar文件中提供,所以我已經把它放在lib文件夾中,但該jar文件包含gson庫,並且它的接縫是過時的。所以我想排除它併爲gson添加單獨的依賴關係。如何從Gradle中的jar文件中排除臨時依賴項?

我該怎麼做? 感謝

UPD

compile fileTree(include: ['*.jar'], dir: 'libs') { 
    exclude group: 'com.google.code.gson', module: 'gson' 
} 

導致錯誤

Error:(49, 0) Gradle DSL method not found: 'exclude()' 

回答

0

可以從這樣的依賴explicityly排除:

compile fileTree(dir: 'libs', include: '*.jar', excludes: ['gson-stuff']) 

我希望這是有幫助的。

+0

對不起它不適用於'fileTree' 所以當我嘗試像這樣 '編譯文件樹(包括:[ '的* .jar'],DIR: '庫'){ 排除組:「com.google 'code.gson',module:'gson' }' 它說'錯誤:(49,0)Gradle DSL method not found:'exclude()' –

+0

更新我的回答 –

+0

如果我這樣做'compile fileTree( 包括:['* .jar'],dir:'libs', 排除:[group:'com.google.code.gson',module:'gson'] )'It says'Error :(49,0)由於:groovy.lang.GroovyRu,無法使用類「java.util.LinkedHashMap」將類「{group = com.google.code.gson,module = gson}」轉換爲類「java.lang.Iterable」 ntimeException:找不到匹配的構造函數:java.lang.Iterable(java.util.LinkedHashMap)' 和順便說一句我認爲'排除'參數是用於排除一些文件或文件夾,並不確定它是否會排除內部依賴關係的jar文件.... –

相關問題