1.Terminal 运行命令
gradlew -q :app:dependencies
查看依赖。
输出示例
+--- com.android.support:appcompat-v7:25.2.0 -> 27.1.1
| +--- com.android.support:support-annotations:27.1.1
| +--- com.android.support:support-core-utils:27.1.1
| | +--- com.android.support:support-annotations:27.1.1
| | \--- com.android.support:support-compat: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-fragment:27.1.1
| | +--- com.android.support:support-compat:27.1.1 (*)
| | +--- com.android.support:support-core-ui: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-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:27.1.1
| | +--- com.android.support:support-annotations:27.1.1
| | \--- com.android.support:support-compat:27.1.1 (*)
| \--- com.android.support:animated-vector-drawable:27.1.1
| +--- com.android.support:support-vector-drawable:27.1.1 (*)
| \--- com.android.support:support-core-ui:27.1.1 (*)
+--- com.android.support:support-v4:27.1.1
| +--- com.android.support:support-compat:27.1.1 (*)
| +--- com.android.support:support-media-compat: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-core-ui:27.1.1 (*)
| \--- com.android.support:support-fragment:27.1.1 (*)
+--- com.android.support:design:27.1.1
分析技巧
- 1直接将输出复制出来到notepad++,使用ctrl+f查找
->
,因为有不同版本,就会使用->
符号列出区别。
冲突解决
- 1.逐个排查(此方法运行报错,还不知道原因)
implementation('junit:junit:4.12'){
exclude group : 'org.hamcrest',module:'hamcrest-core'
}
//最终,如果我们向包含1.3版本到构建中,我们可以从“mockito"中排除他
androidTestImplementatione('org.mockito:mockito-core:1.10.19'){
exclude group : 'org.hamcrest',module:'hamcrest-core'
}
- 3.强制指定
//在app.gradle 中的Android闭包中使用
configurations.all{
resolutionStrategy{
force 'com.android.support:support-v4:27.1.1'
force 'com.android.support:appcompat-v7:27.1.1'
}
}
//在build.gradle 中设置工程全局强制依赖
allprojects{
configurations.all {
resolutionStrategy.force 'com.android.support:appcompat-v7:28.0.0'
resolutionStrategy.force 'com.android.support:support-v4:28.0.0'
resolutionStrategy.force 'com.android.support:animated-vector-drawable:28.0.0'
resolutionStrategy.force 'com.android.support:support-media-compat:28.0.0'
}
}
也有人这样写build.gradle
configurations.all{
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '27.1.1'
}
}
}
}
网友评论