1. 查看依赖树
./gradlew app:dependencies --configuration releaseRuntimeClasspath
+--- com.android.support.constraint:constraint-layout:1.1.2
| \--- com.android.support.constraint:constraint-layout-solver:1.1.2
+--- com.android.support:appcompat-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| +--- com.android.support:support-v4:26.1.0
| | +--- com.android.support:support-compat:26.1.0 -> 27.1.1
| | | +--- com.android.support:support-annotations:27.1.1
| | | \--- android.arch.lifecycle:runtime:1.1.0
| | | +--- android.arch.lifecycle:common:1.1.0
| | | \--- android.arch.core:common:1.1.0
| | +--- com.android.support:support-media-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| | | \--- com.android.support:support-compat:26.1.0 -> 27.1.1 (*)
| | +--- com.android.support:support-core-utils:26.1.0 -> 27.1.1
| | | +--- com.android.support:support-annotations:27.1.1
| | | \--- com.android.support:support-compat:27.1.1 (*)
| | +--- com.android.support:support-core-ui:26.1.0 -> 27.1.1
| | | +--- com.android.support:support-annotations:27.1.1
| | | +--- com.android.support:support-compat:27.1.1 (*)
| | | \--- com.android.support:support-core-utils:27.1.1 (*)
| | \--- com.android.support:support-fragment:26.1.0 -> 27.1.1
| | +--- com.android.support:support-compat:27.1.1 (*)
| | +--- com.android.support:support-core-ui:27.1.1 (*)
| | +--- com.android.support:support-core-utils:27.1.1 (*)
| | +--- com.android.support:support-annotations:27.1.1
| | +--- android.arch.lifecycle:livedata-core:1.1.0
| | | +--- android.arch.lifecycle:common:1.1.0
| | | +--- android.arch.core:common:1.1.0
| | | \--- android.arch.core:runtime:1.1.0
| | | \--- android.arch.core:common:1.1.0
| | \--- android.arch.lifecycle:viewmodel:1.1.0
| +--- com.android.support:support-vector-drawable:26.1.0
| | +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| | \--- com.android.support:support-compat:26.1.0 -> 27.1.1 (*)
| \--- com.android.support:animated-vector-drawable:26.1.0
| +--- com.android.support:support-vector-drawable:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 -> 27.1.1 (*)
+--- com.android.support:recyclerview-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| +--- com.android.support:support-compat:26.1.0 -> 27.1.1 (*)
| \--- com.android.support:support-core-ui:26.1.0 -> 27.1.1 (*)
\--- com.github.bumptech.glide:glide:4.7.1
+--- com.github.bumptech.glide:gifdecoder:4.7.1
| \--- com.android.support:support-annotations:27.1.1
+--- com.github.bumptech.glide:disklrucache:4.7.1
+--- com.github.bumptech.glide:annotations:4.7.1
\--- com.android.support:support-fragment:27.1.1 (*)
符号的含义:
x.x.x () 该依赖已经有了,将不再重复依赖。
x.x.x -> x.x.x 该依赖的版本被箭头所指的版本代替。
x.x.x -> x.x.x() 该依赖的版本被箭头所指的版本代替,并且该依赖已经有了,不再重复依赖。
2. Exclude 排除
排除所有:
// 在build.gradle 中添加下面节点
configurations {
all*.exclude module: "support-fragment"
}
排除指定:
- 非本地项目
implementation ('com.github.bumptech.glide:glide:4.7.1'){
exclude module:"support-fragment"
}
- 本地项目
compile(project(':xxx')) {
exclude group: 'com.facebook.react', module: 'react-native'
}
3. Force 强制指定
强制所有:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-fragment:26.1.0'
}
}
强制指定:
// 在build.gradle 中添加下面节点
implementation ( 'com.meituan.android.pay.quickpass.baseinterface:library:1.0.0') {
force = true
}