Output differing between `dependencies` and `androidDependencies`

Viewed 65

What are the differences between

./gradlew :app:dependencies

and

./gradlew :app:androidDependencies

?

All I've been able to notice is that androidDependencies includes .jar and .aar in the output graph. Why is this the case and is there a way to include these files in the dependency output via dependencies?

1 Answers

You can run ./gradlew :app:tasks to see a short description of each Gradle task that is runnable in the :app project. The description that I see for each of the androidDependencies and dependencies Gradle tasks is as follows:

androidDependencies - Displays the Android dependencies of the project.
dependencies - Displays all dependencies declared in project ':app'.

Sadly, the descriptions here don't do a great job of differentiating between the two Gradle tasks. However, on running each of the two Gradle tasks, I see two differences in the output, as follows:

  1. The androidDependencies task calls out whether the library is packaged as an aar or a jar. The dependencies task does not offer this information. (You have already called this difference out in your question.)
  2. The androidDependencies task prints a flattened list of the project's dependencies. The dependencies task, on the other hand, prints a nested graph of the project's dependencies.

A further difference between the two tasks is that you can provide a --configuration option to the dependencies task to restrict its output to a single configuration. For example, if you run ./gradlew :app:dependencies --configuration debugCompileClasspath, this will only display the dependencies for the debugCompileClasspath configuration. The --configuration option is not available for the androidDependencies task.

Related