others-how to print dependency tree in android studio ?

1. Purpose

In this post, I will show you how to print dependency tree in android studio.

2. Solution

Open terminal in the app , and input the following command:

gradle dependencies

The you will see the dependency tree of your app.

Gradle provides the built-in dependencies task to render a dependency tree from the command line. By default, the dependency tree renders dependencies for all configurations within a single project. The dependency tree indicates the selected version of each dependency. It also displays information about dependency conflict resolution.

The dependencies task can be especially helpful for issues related to transitive dependencies. Your build file lists direct dependencies, but the dependencies task can help you understand which transitive dependencies resolve during your build.

You can also specify the configuration when printing the dependency tree in commandline as follows:

gradle -q dependencies --configuration testRuntimeClasspath

To see a list of all the configurations available in a project, including those added by any plugins, you can run a resolvableConfigurations report.

Here is an example:

If your build.gradle is:

repositories {
    mavenCentral()
}

configurations {
    scm
}

dependencies {
    scm 'org.eclipse.jgit:org.eclipse.jgit:4.9.2.201712150930-r'
}

Then you can print your dependency tree as follows:

> gradle -q dependencies --configuration scm

------------------------------------------------------------
Root project 'dependencies-report'
------------------------------------------------------------

scm
\--- org.eclipse.jgit:org.eclipse.jgit:4.9.2.201712150930-r
     +--- com.jcraft:jsch:0.1.54
     +--- com.googlecode.javaewah:JavaEWAH:1.1.6
     +--- org.apache.httpcomponents:httpclient:4.3.6
     |    +--- org.apache.httpcomponents:httpcore:4.3.3
     |    +--- commons-logging:commons-logging:1.1.3
     |    \--- commons-codec:commons-codec:1.6
     \--- org.slf4j:slf4j-api:1.7.2

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

Alternatively , you can just use the dependencyInsight as follows:

Dependency Insights. Gradle provides the built-in dependencyInsight task to render a dependency insight report from the command line. Dependency insights provide information about a single dependency within a single configuration. Given a dependency, you can identify the selection reason and origin.

For example, you cau use dependencyInsight to view a specific dependency’s detail:

> gradle -q dependencyInsight --dependency commons-codec --configuration scm
commons-codec:commons-codec:1.7
  Variant default:
    | Attribute Name    | Provided | Requested |
    |-------------------|----------|-----------|
    | org.gradle.status | release  |           |
   Selection reasons:
      - By conflict resolution: between versions 1.7 and 1.6

commons-codec:commons-codec:1.7
\--- scm

commons-codec:commons-codec:1.6 -> 1.7
\--- org.apache.httpcomponents:httpclient:4.3.6
     \--- org.eclipse.jgit:org.eclipse.jgit:4.9.2.201712150930-r
          \--- scm

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



3. Summary

In this post, I demonstrated how to print dependency tree in android studio . That’s it, thanks for your reading.