包冲突依赖分析

分析依赖

常见指令

  • 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

参考

QA

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容