Android技术收集

查看Android Gradle 依赖树

2020-11-27  本文已影响0人  maoai_xianyu

查看Android Gradle 依赖树

方式一: ./gradlew :模块名:dependencies //查看单独模块的依赖

这个命令会将 gradle 执行的各个步骤全打印出来,包括引用的库,和库中引用的库文件

可以配置 configuration 参数只查看 implementation 的依赖树。

------------------------------------------------------------
Project :app
------------------------------------------------------------

implementation - Implementation only dependencies for 'main' sources. (n)
+--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.4.20 (n)
+--- unspecified (n)
+--- androidx.appcompat:appcompat:1.1.0 (n)
+--- com.google.android.material:material:1.2.1 (n)
+--- androidx.constraintlayout:constraintlayout:2.0.4 (n)
+--- org.jetbrains.kotlin:kotlin-stdlib:1.4.20 (n)
+--- androidx.core:core-ktx:1.3.2 (n)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1 (n)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1 (n)
+--- com.android.volley:volley:1.1.1 (n)
+--- com.google.code.gson:gson:2.8.6 (n)
\--- com.github.bumptech.glide:glide:4.8.0 (n)

(n) - Not resolved (configuration is not meant to be resolved)

参考使用Gradle查看Android项目中库的依赖关系

$ ./gradlew :app:dependencyInsight --dependency fastjson --configuration compile

:app:dependencyInsight
com.android.support:support-annotations:25.3.1
+--- com.afollestad.material-dialogs:core:0.9.4.5
|    \--- compile
+--- com.android.support:appcompat-v7:25.3.1
|    +--- compile
|    +--- com.android.support:design:25.3.1
|    |    \--- compile
|    +--- com.afollestad.material-dialogs:core:0.9.4.5 (*)
|    \--- me.zhanghai.android.materialprogressbar:library:1.4.1
|         \--- com.afollestad.material-dialogs:core:0.9.4.5 (*)
+--- com.android.support:recyclerview-v7:25.3.1
|    +--- compile
|    +--- com.android.support:design:25.3.1 (*)
|    \--- com.afollestad.material-dialogs:core:0.9.4.5 (*)
+--- com.android.support:support-compat:25.3.1
|    +--- com.android.support:support-v4:25.3.1
|    |    +--- compile
|    |    +--- com.android.support:appcompat-v7:25.3.1 (*)
|    |    +--- com.android.support:design:25.3.1 (*)
|    |    +--- com.alibaba:arouter-api:1.2.1.1
|    |    |    \--- compile
|    |    +--- com.android.support:transition:25.3.1
|    |    |    \--- com.android.support:design:25.3.1 (*)
|    |    \--- com.android.support:support-v13:25.3.1
|    |         \--- com.afollestad.material-dialogs:core:0.9.4.5 (*)
|    +--- com.android.support:recyclerview-v7:25.3.1 (*)
|    +--- com.android.support:support-vector-drawable:25.3.1
|    |    +--- com.android.support:appcompat-v7:25.3.1 (*)
|    |    \--- com.android.support:animated-vector-drawable:25.3.1
|    |         \--- com.android.support:appcompat-v7:25.3.1 (*)
|    +--- com.android.support:support-media-compat:25.3.1
|    |    +--- com.android.support:support-v4:25.3.1 (*)
|    |    \--- com.android.support:support-fragment:25.3.1
|    |         \--- com.android.support:support-v4:25.3.1 (*)
|    +--- com.android.support:support-core-utils:25.3.1
|    |    +--- com.android.support:support-v4:25.3.1 (*)
|    |    \--- com.android.support:support-fragment:25.3.1 (*)
|    +--- com.android.support:support-core-ui:25.3.1
|    |    +--- com.android.support:support-v4:25.3.1 (*)
|    |    +--- com.android.support:recyclerview-v7:25.3.1 (*)
|    |    \--- com.android.support:support-fragment:25.3.1 (*)
|    \--- com.android.support:support-fragment:25.3.1 (*)
+--- com.android.support:support-core-ui:25.3.1 (*)
+--- com.android.support:support-core-utils:25.3.1 (*)
+--- com.android.support:support-media-compat:25.3.1 (*)
+--- com.android.support:support-v13:25.3.1 (*)
+--- com.android.support:support-vector-drawable:25.3.1 (*)
+--- com.android.support:transition:25.3.1 (*)
\--- me.zhanghai.android.materialprogressbar:library:1.4.1 (*)
 
(*) - dependencies omitted (listed previously)
 
BUILD SUCCESSFUL
 
Total time: 13.388 secs复制代码

参考 Gradle 理解:configuration、dependency

$ ./gradlew :app:dependencyInsight --configuration debugCompileClasspath --dependency gson


> Task :app:dependencyInsight

com.google.code.gson:gson:2.8.6
   variant "compile" [
      org.gradle.status                              = release (not requested)
      org.gradle.usage                               = java-api
      org.gradle.libraryelements                     = jar (not requested)
      org.gradle.category                            = library (not requested)

      Requested attributes not found in the selected variant:
         com.android.build.api.attributes.BuildTypeAttr = debug
         org.jetbrains.kotlin.platform.type             = androidJvm
   ]
   Selection reasons:
      - By constraint : debugRuntimeClasspath uses version 2.8.6

com.google.code.gson:gson:2.8.6
\--- debugCompileClasspath

com.google.code.gson:gson:{strictly 2.8.6} -> 2.8.6
\--- debugCompileClasspath

A web-based, searchable dependency report is available by adding the --scan option.

方式二: 使用Gradle Project,在控制台输出

参考Android 查看项目依赖树的四种方式

image.png

方式三: 安装Android Studio插件 gradle view

参考Android 查看项目依赖树的四种方式

image.png

方式四: ./gradlew build --scan 没有打开生成的网址

If you require assistance with this problem, please report it via https://gradle.com/help/plugin and include the following information via copy/paste.

----------
Gradle version: 6.5
Plugin version: 3.3.3
Request URL: https://scans-in.gradle.com/scans/publish/gradle/3.3.3/token
Request ID: d67d1c2f-fe9c-4318-9d0f-48b8cec58ced
Exception: java.net.ConnectException: Connection refused (Connection refused)
----------

方式五: ./gradlew :模块名字:dependencies > 文件名字.txt

./gradlew :app:dependencies > test.txt
上一篇下一篇

猜你喜欢

热点阅读