Gradle: Print Dependency Graph On Terminal for Android

Easy way to visualize and list the dependency tree using Gradle tasks

While using dependencies in your Android projects sometimes it’s natural for some strange errors to pop which do not make any sense. For instance, suddenly a firebase dependency seems broken when you add a different dependency. Sometimes you can have dependencies that do support incremental builds.

But as the dependency graph grows, it becomes harder to visualize which dependency has a different version.

If you are facing issues with your Gradle builds in Android Studio because of your dependencies try to print the dependency tree of your project and take a look at what dependencies each library has and exclude them. You can also check which of these support incremental builds here.

Because dependencies which do not support incremental build slows you down and makes your compilation slow.

To print the dependency graph for all dependencies of the app module.

Go to the terminal and type in the root folder.

gradle :app:dependencies

or

gradle app:dependencies

This should already do the trick.

Sometimes if you are setup needs gradlewrapper executable to be specified explicitly. Use…

./gradlew app:dependencies

You can also read this into a file or extract it to HTML for easy readability or storing.

First add this plugin to your app gradle file.

apply plugin: 'project-report'

You can generate a HTML report,

$ ./gradlew htmlDependencyReport

If you found this useful clap and share :)

Freelance Android Engineer. Founder at www.coderbee.de. Buy Me A Coffee if you find my blog useful: https://www.buymeacoffee.com/badrobot

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store