切换到要查看项目的目录,执行命令gradlew :app:dependencies,查看依赖树
从上图可以看出红色框中有开源库以来的版本比当前的版本低,因此可以使用exclude剔除旧版本库,避免重复,也可以瘦身apk
compile ('com.jakewharton:butterknife:8.8.1'){
exclude module: 'support-annotations'
exclude module: 'support-compat'
}
force强制设置某个模块的版本。
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:25.3.0'
}
}
Transitive用于自动处理子依赖项。默认为true,gradle自动添加子依赖项,形成一个多层树形结构;设置为false,则需要手动添加每个依赖项。