Gradle依赖总结
查找整个项目依赖关系树
要想查看整个项目的依赖传递关系,使用命令:
gradlew :app:dependencies --configuration releaseRuntimeClasspath
其中app是项目的模块名称
运行以后查找结果中的含义如下
- x.x.x (*) 该依赖已经有了,将不再重复依赖
- x.x.x -> x.x.x 该依赖的版本被箭头所指的版本代替
- x.x.x -> x.x.x(*) 该依赖的版本被箭头所指的版本代替,并且该依赖已经有了,不再重复依赖
gradle依赖冲突的解决方式
- exclude关键字
implementation('androidx.constraintlayout:constraintlayout:1.1.3') {
//解决冲突第一种排除方式
exclude group: 'androidx.constraintlayout', module: 'constraintlayout-solver'
}
- configuration配置
//定义配置名称
configurations {
//自定义配置名称
abc {
println 'abc'
}
//第二种方式解决冲突
configuration {
all*.exclude module: 'annotation'
}
//第三种方式解决冲突,强制指定
all {
resolutionStrategy {
force 'androidx.fragment:fragment:1.0.0'
}
}
}
- 强制指定
//第三种方式解决冲突,强制指定
configurations.all {

最低0.47元/天 解锁文章
915

被折叠的 条评论
为什么被折叠?



