2017-04-05 105 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文件.... –

相关问题