gradle排除组编译 [英] gradle exclude group from compile
问题描述
构建我的应用程序时出现此重复错误:
I am getting this duplicate error when building my app:
addJar(... facebookadapter-4.0.3.jar): entry
重复项:com / facebook / ads / AbstractAdListener.class
addJar(...facebookadapter-4.0.3.jar): entry
duplicate entry: com/facebook/ads/AbstractAdListener.class
我得到这个的原因是我的应用程序编译了Facebook模块,一个属于适配器,一个属于其原始SDK:
The reason I am getting this is that my app compiles Facebook modules one belongs to an adapter and one to its original SDK:
compile('com.ironsource.adapters:facebookadapter :4.0.3@jar')
编译'com.facebook.android:audience-network-sdk:4.27.0'
编译'com.google.ads.mediation:facebook:4.27.0.0'
compile ('com.ironsource.adapters:facebookadapter:4.0.3@jar') compile 'com.facebook.android:audience-network-sdk:4.27.0' compile 'com.google.ads.mediation:facebook:4.27.0.0'
因此,作为解决方案,我试图从包含适配器jar编译语句的模块中排除该组:
So as a solution, I am trying to exclude this group from the module which contains the adapter jar compile statement:
compile ('com.ironsource.adapters:facebookadapter:4.0.3@jar') {
exclude (group: 'com/facebook/ads')
}
但是,当我再次构建应用程序时,它无法陈述相同的原因来自同一适配器
But, when I build my app again it fails to state the same reason from the same adapter
任何不知道为什么不排除类的想法吗?
Any idea why the classes are not being excluded?
推荐答案
看起来像 exclude
块语法不正确。尝试
Looks like the exclude
block syntax is incorrect. Try
compile ('com.ironsource.adapters:facebookadapter:4.0.3@jar') {
exclude group: 'com.facebook.ads'
}
更新
所以 facebookadatpeter
似乎包含了此类。您不能从 jar
文件中排除一个类,排除只在每个依赖级别上起作用。
So it looks like the facebookadatpeter
contains this class inside. You can not exclude a class from a jar
file, exclusion only works on per-dependency level.
如果绝对需要此适配器,您可以尝试从所有其他依赖项中排除facebook广告的传递依赖项。
If you absolutely need to have this adapter, you can try to exclude facebook ads transitive dependency from all the other dependencies.
configurations {
all*.exclude group: 'com.facebook.ads'
}
这篇关于gradle排除组编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!