How do I show dependencies tree in Android Studio?

AndroidAndroid StudioGradleIntellij IdeaAndroid Gradle-Plugin

Android Problem Overview


My goal is to see the tree of dependencies (such as: appcompat, dagger, etc) in a particular project.

Like the one IntelliJ:

enter image description here

Android Solutions


Solution 1 - Android

The image in the question doesn't really show a tree, just a flat list of everything compiled into the app.

Are you using Gradle?

If so, you can truly see the "tree" by running a Gradle command

Android documentation: View the dependency tree

GUI

> 1. Select View > Tool Windows > Gradle (or click Gradle icon in the tool windows bar). > 2. Expand AppName > Tasks > android and double-click androidDependencies. After Gradle executes the task, the Run window > should open to display the output.

CLI

(produces tree-like list)

./gradlew app:dependencies

and/or

(produces flat list)

./gradlew app:androidDependencies

Where app is your module's name

And you get something like so

+--- MyApp:mylibrary:unspecified
|    \--- com.android.support:appcompat-v7:25.3.1
|         +--- com.android.support:animated-vector-drawable:25.3.1
|         |    \--- com.android.support:support-vector-drawable:25.3.1
|         |         \--- com.android.support:support-v4:25.3.1
|         |              \--- LOCAL: internal_impl-25.3.1.jar
|         +--- com.android.support:support-v4:25.3.1
|         |    \--- LOCAL: internal_impl-25.3.1.jar
|         \--- com.android.support:support-vector-drawable:25.3.1
|              \--- com.android.support:support-v4:25.3.1
|                   \--- LOCAL: internal_impl-25.3.1.jar
\--- com.android.support:appcompat-v7:25.3.1
     +--- com.android.support:animated-vector-drawable:25.3.1
     |    \--- com.android.support:support-vector-drawable:25.3.1
     |         \--- com.android.support:support-v4:25.3.1
     |              \--- LOCAL: internal_impl-25.3.1.jar
     +--- com.android.support:support-v4:25.3.1
     |    \--- LOCAL: internal_impl-25.3.1.jar
     \--- com.android.support:support-vector-drawable:25.3.1
          \--- com.android.support:support-v4:25.3.1
               \--- LOCAL: internal_impl-25.3.1.jar

For specific flavor use the command

gradle app:dependencies --configuration <flavorNameRuntimeClasspath>

Note: If you run ls (or dir on Windows) in that folder, and don't see gradlew (or gradlew.bat), you are in the wrong folder.

Solution 2 - Android

On the right side, open the gradle tab > click the gradle icon (execute gradle task), in the popup dialog enter :

app:dependencies

in the command line field > ok

Solution 3 - Android

Android Studio 3.+

  • Open the Gradle panel
  • Click the elephant icon, which has the tooltip "Execute Gradle Task"

Gradle panel screenshot + elephant icon

  • Select the app gradle project
  • In the command line paste: dependencies
  • Click OK

Screenshot: Run Gradle Task - Window

In the Run panel you will find the dependency tree.


Another method:

  • Open the Gradle panel

  • Find the "(root)" postfix and open (app's folder name)

  • Open the Tasks node

  • Open the android node

  • Double click on the "androidDependencies"

In the Run panel you will find the dependency list

Before a normal build switch back to the normal Build Configuration (next to the hammer)


Another useful tool:

How to find what dependency is updated: https://github.com/ben-manes/gradle-versions-plugin

Usage

  • Add this to project level build.gradle

     apply plugin: "com.github.ben-manes.versions"
    
     buildscript {
       repositories {
         jcenter()    
       }
     
       dependencies {
         classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0"
       }
     }
    
  • Sync Now

  • Open the Gradle panel

  • Click the elephant icon

  • Select the root project

  • In the command line paste: dependencyUpdates

  • Click OK

  • Wait a little bit

In the Run panel you will find the result.

Solution 4 - Android

Android Studio 3.4

Inspect and visualize each dependency in the dependency graph of your project, as resolved by Gradle during project sync, by following these steps:

  1. Android Studio -> File -> Project Structure (Dialog)
  2. In the left pane of the "Project Structure" window, select Dependencies.
  3. In the Modules pane, select a module for which you’d like to inspect the resolved dependencies.

Project Structure

  1. For Android Studio 3.6 and above: On the right side of the "Project Structure" window, look at the Resolved Dependencies pane. An example is shown below, where you can click on the Expand arrows to navigate into each sub-dependency. However, it does not allow text searching, like the console output does.

Resolved Dependencies Pane

Learn more.

Solution 5 - Android

Finally, I figured it out. What I do is to select Project from Project menu (See the image below).

enter image description here

Solution 6 - Android

terminal command to see all dependencies list is

 ./gradlew -q dependencies app:dependencies --configuration implementation

Solution 7 - Android

> Click the Gradle tab and go to AppName > Tasks > help > dependencies

Android studio dependencies

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfruqiView Question on Stackoverflow
Solution 1 - AndroidOneCricketeerView Answer on Stackoverflow
Solution 2 - AndroidJimmyFlashView Answer on Stackoverflow
Solution 3 - AndroidnorbDEVView Answer on Stackoverflow
Solution 4 - AndroidAnorView Answer on Stackoverflow
Solution 5 - AndroidfruqiView Answer on Stackoverflow
Solution 6 - Androidvikas kumarView Answer on Stackoverflow
Solution 7 - AndroidWirlingView Answer on Stackoverflow