Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
117 views
in Technique[技术] by (71.8m points)

How do I show dependencies tree in Android Studio?

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...