android - gradle - library duplicates in dependencies -
i have android project gradle. problem is: in project
view see few versions of support-v4
libraries, example support-v4-21.0.3
, support-v4-22.2.0
.
but in build.gradle
don't have support-v4
@ all.
but have ~10 other dependencies in build.gradle
. example appcompat-v7:22.2.0
. can suggests appcompat-v7:22.2.0
depens on support-v4-22.2.0
in maven dependencies , implicitly pulls it. have no ideas pulls support-v4-21.0.3
.
as far know libs packed in apk , increase weight of apk.
so have next questions:
- how avoid library duplicates?
- how see maven dependencies in android studio?
- how detect library require library? example library require
support-v4-21.0.3
in project?
to find duplicate dependencies or required dependencies, can visualize library dependencies in tree. execute gradle command below.
gradle -q dependencies yourproject:dependencies --configuration compile
note that, run gradlew
in windows below.
gradlew -q dependencies yourproject:dependencies --configuration compile
the command result show human-readable tree hierarchy of dependencies below.
compile - classpath compiling main sources. +--- org.androidannotations:androidannotations-api:3.2 +--- com.android.support:support-annotations:22.1.1 +--- com.squareup:otto:1.3.6 +--- in.srain.cube:grid-view-with-header-footer:1.0.10 +--- com.nostra13.universalimageloader:universal-image-loader:1.9.3 +--- com.github.chrisbanes.photoview:library:1.2.3 +--- org.simpleframework:simple-xml:2.7.1 +--- com.google.android.gms:play-services-base:6.5.+ -> 6.5.87 +--- project :yourproject | +--- com.loopj.android:android-async-http:1.4.6 | +--- org.apache.httpcomponents:httpmime:4.2.5 | | \--- org.apache.httpcomponents:httpcore:4.2.4 | \--- com.google.code.gson:gson:2.3.1 +--- project :facebook | \--- com.android.support:appcompat-v7:22.1.1 | \--- com.android.support:support-v4:22.1.1 | \--- com.android.support:support-annotations:22.1.1 -> 22.2.0
you can see overriden dependencies , decide in mind ones should avoided. in above example, last line com.android.support:support-annotations
presents overriden 22.1.1
22.2.0
internally.
to avoid duplicates, can add exclude
clauses in each project build.gradle
file.
compile('com.github.chrisbanes.photoview:library:1.2.3') { exclude group: 'com.android.support' } compile('org.simpleframework:simple-xml:2.7.1') { exclude module: 'stax' exclude module: 'stax-api' exclude module: 'xpp3' } compile('com.google.android.gms:play-services-base:6.5.+') { exclude module: 'support-v4' }
for more information, can see tutorial @ https://docs.gradle.org/current/userguide/userguide_single.html#sec:listing_dependencies
Comments
Post a Comment