Gradle: Print Dependency Graph On Terminal for Android
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.
These kinda problems arise because the libraries using certain dependencies might have a different version of the dependency than you do.
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.
This should already do the trick.
Sometimes if you are setup needs gradlewrapper executable to be specified explicitly. Use…
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 :)