For some reason I have using java 1.7 to compile my project, but I'm facing duplicate entry error when compile the project. Below is my dependencies tree that showing the duplicate.
+--- com.google.firebase:firebase-analytics:10.2.0
| +--- com.google.firebase:firebase-common:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0
| | | \--- com.android.support:support-v4:24.0.0
| | | \--- com.android.support:support-annotations:24.0.0
| | \--- com.google.android.gms:play-services-tasks:10.2.0
| | \--- com.google.android.gms:play-services-basement:10.2.0 (x)
| +--- com.google.firebase:firebase-analytics-impl:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0 (x)
| | +--- com.google.firebase:firebase-iid:10.2.0
| | | +--- com.google.android.gms:play-services-basement:10.2.0 (x)
| | | \--- com.google.firebase:firebase-common:10.2.0 (x)
| | +--- com.google.firebase:firebase-common:10.2.0 (x)
| | \--- com.google.android.gms:play-services-tasks:10.2.0 (x)
| \--- com.google.android.gms:play-services-basement:10.2.0 (x)
I have tried to add exclude when I compile the firebase-analytics libs, but it looks like only the first layer will be excluded, and not all. Can anyone help?
compile ('com.google.firebase:firebase-analytics:10.2.0'){
exclude group: 'com.google.android.gms', module: 'play-services-basement:10.2.0'
}
dependencies block:
dependencies {
compile project(":core")
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.code.gson:gson:2.7'
compile ('com.google.firebase:firebase-core:10.2.0'){
exclude group: 'com.google.android.gms', module: 'play-services-basement'
}
compile fileTree(dir: "${rootProject.projectDir}/android-libs", include: ['*.jar'])
compile "org.slf4j:slf4j-android:1.7.10"
}
How to exclude transitive dependencies in gradle? This section talks about exclude at runtime and compile time for each dependency exclude runtime dependency: Some times, You have transitive dependencies which are causing conflict with version of direct dependency. This excludes the dependency library from given ouput jar or war file
In plain Gradle, what you are looking for can be achieved as: dependencies { compile ('com.example.m:m:1.0') { exclude group: 'org.unwanted', module: 'x } compile 'com.example.l:1.0' } This would exclude the module X from the dependencies of M, but will still bring it if you depend on L.
When Gradle encounters two different versions of the same dependency, it will perform a conflict resolution. It defaults to choosing the highest version number.
On the upside, Gradle’s exclude handling is, in contrast to Maven, taking the whole dependency graph into account. So if there are multiple dependencies on a library, excludes are only exercised if all dependencies agree on them.
You can try to use configuration-wide exclusion as follows:
configurations.all {
exclude group: 'com.google.android.gms', module: 'play-services-basement'
}
Or just exlude it from compile configuration only:
configurations {
compile.exclude group: 'com.google.android.gms', module: 'play-services-basement'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With