When I have an aar
library how to list all the dependencies of this aar ? for exemple i have facebook-core-5.15.1.aar
and the dependencies are :
+--- com.facebook.android:facebook-core:5.15.1
| +--- com.parse.bolts:bolts-android:1.4.0
| | +--- com.parse.bolts:bolts-tasks:1.4.0
| | --- com.parse.bolts:bolts-applinks:1.4.0
| | --- com.parse.bolts:bolts-tasks:1.4.0
| +--- com.android.support:support-annotations:27.0.2
| +--- com.android.support:support-core-utils:27.0.2
| | +--- com.android.support:support-annotations:27.0.2
| | --- com.android.support:support-compat:27.0.2
| | +--- com.android.support:support-annotations:27.0.2
| | --- android.arch.lifecycle:runtime:1.0.3
| | +--- android.arch.lifecycle:common:1.0.3
| | --- android.arch.core:common:1.0.0
| --- com.android.installreferrer:installreferrer:1.1
How to retrieve this dependencies tree from a command line? and accessory how to know where to download all thoses dependencies?
I need to know this because as far as I know If I add com.facebook.android:facebook-core:5.15.1.aar
in my project without adding com.parse.bolts:bolts-android:1.4.0.aar
(for exemple), then my project will not work.
In the research I did I found this way to know all the dependencies needed by a libraries, I must create a android studio project, add the dependencies like this:
dependencies {
implementation 'com.facebook.android:facebook-core:5.15.1'
}
and then run: gradlew app:dependencies
But I want to avoid to create an android project and I need to automate the task from a command line
4
Answers
AFAIK, when you run
./gradlew app:dependencies
command, it will report all dependencies of theapp
module, no command for specific library’s dependencies report. However, Android Studio have the resolved dependencies report (after synced project), you may check if it is your need.File > Project Structure > Dependencies menu > Your modules (app) > Resolved dependencies.
List of dependencies can be found on mvnrepository.com or search.maven.org
You can write a program that will parse these sites and give out data in the desired format
P.S.
Resolving child dependencies is one of the main purposes of gradle. The fact that you have to manually write child dependencies indicates that you have some kind of error in the configuration (maybe a newer version of the dependency is already included)
You might be looking for something already existing, for example:
https://github.com/status-im/go-maven-resolver. Usage:
Although it gives you dependency URLs, but you can easily parse them to get GAV coordinates, or modify the script to print out the tree-like structure.
A library (aar or jar) does not contain any dependency informations by itself. However, libraries are
generally available in Maven repositories, and such repositories provide dependency informations via
POM files (which are XML files).
The URL where a POM file is available can be constructed from the following elements:
The main repository is Maven Central. Its URL is
https://repo1.maven.org/maven2/
. Most libraries areavailable there.
For
com.facebook.android:facebook-core:5.15.1
, the POM URL is:https://repo1.maven.org/maven2/com/facebook/android/facebook-core/5.15.1/facebook-core-5.15.1.pom
The file contains a
<dependencies>
element:Only the direct dependencies are listed. To get the so-called "transitive dependencies", you need to iterate
the process and fetch the POM files of the dependencies.
Note that Google publishes its Android libraries in its own Maven repository, at this URL:
https://maven.google.com/
So, for
com.google.firebase:firebase-messaging:12.0.1
, the POM URL is:https://maven.google.com/com/google/firebase/firebase-messaging/12.0.1/firebase-messaging-12.0.1.pom