包冲突依赖分析
2022-05-25 本文已影响0人
CentForever
分析依赖
常见指令
- gradlew :app:dependencyInsight --configuration debugCompileClasspath --dependency work-runtime
- ./gradlew -q :ecabin:dependencyInsight --dependency support-annotations --configuration compile
- ./gradlew :app:androidDependencies
- 指令前的:app是你的module名
- configuration 参数用于指定 variant,例如你还可以传入 releaseCompileClasspath
─ ~/AndroidStudioProjects/FileDownloader ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── at 16:39:12 ─╮
╰─❯ ./gradlew :app:dependencyInsight --configuration debugCompileClasspath --dependency work-runtime ─╯
> Task :app:dependencyInsight
No dependencies matching given input were found in configuration ':app:debugCompileClasspath'
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
╭─ ~/AndroidStudioProjects/FileDownloader ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── at 16:40:20 ─╮
╰─❯ ./gradlew :ecabin:dependencyInsight --configuration debugCompileClasspath --dependency work-runtime ─╯
> Task :ecabin:dependencyInsight
androidx.work:work-runtime:2.7.1
variant "releaseVariantReleaseApiPublication" [
org.gradle.category = library (not requested)
org.gradle.dependency.bundling = external (not requested)
org.gradle.libraryelements = aar (not requested)
org.gradle.usage = java-api
org.gradle.status = release (not requested)
Requested attributes not found in the selected variant:
com.android.build.api.attributes.BuildTypeAttr = debug
org.gradle.jvm.environment = android
com.android.build.api.attributes.AgpVersionAttr = 7.2.0
]
Selection reasons:
- By constraint : debugRuntimeClasspath uses version 2.7.1
androidx.work:work-runtime:2.7.1
\--- debugCompileClasspath
androidx.work:work-runtime:{strictly 2.7.1} -> 2.7.1
\--- debugCompileClasspath
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
注意事项
- gradle.properties 添加org.gradle.java.home=/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home
参考
- 解决gradle依赖冲突最佳实践 https://www.jianshu.com/p/8c3f0e0f93ab
- 一次解决依赖库冲突的历程 https://www.jianshu.com/p/e69f4641c5b3
- 查看安卓依赖树 ./gradlew :ecabin:dependencies || ./gradlew :app:dependencies > log.txt
- 如何查看模块的所有依赖 https://blog.csdn.net/qq_34908601/article/details/123942340