gradle exclude group from compile
Looks like the exclude
block syntax is incorrect. Try
compile ('com.ironsource.adapters:facebookadapter:4.0.3@jar') {
exclude group: 'com.facebook.ads'
}
Update
So it looks like the facebookadapter
contains this class inside. You can not exclude a class from a jar
file, exclusion only works on per-dependency level.
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'
}
Michael A
Updated on June 09, 2022Comments
-
Michael A almost 2 years
I am getting this duplicate error when building my app:
addJar(...facebookadapter-4.0.3.jar): entry
duplicate entry: com/facebook/ads/AbstractAdListener.classThe 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') compile 'com.facebook.android:audience-network-sdk:4.27.0' compile 'com.google.ads.mediation:facebook:4.27.0.0'
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?
-
Nikita Skvortsov over 6 yearsuse
gradlew :app:dependencyInsight --configuration compile --dependency com.facebook.ads
to check where the dependency comes from
-
-
Michael A over 6 yearsThat was my first try, both syntaxes give the same result
-
Nikita Skvortsov over 6 yearsoh, so the class is inside the jar. That makes problem tricker, please see my update
-
Michael A over 6 yearsThanks, can you please elaborate on this line "You can not exclude a class from a jar file, exclusion only works on per-dependency level"
-
Nikita Skvortsov over 6 yearsEach dependecy declaration in Gradle defines a subtree:not only the actual library (a single jar file), but all the dependencies of this library as well (transitive dependencies, multiple jar files). The
exclude
directive allows you to exclude some of transitive dependencies (exclude several jar files). In case ofcom.ironsource.adapters:facebookadapter:4.0.3@jar
thecom/facebook/ads/AbstractAdListener.class
is a part of library, not a transitive dependency, you can not exclude it this way