skip to Main Content

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


  1. AFAIK, when you run ./gradlew app:dependencies command, it will report all dependencies of the app 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.

    enter image description here

    Login or Signup to reply.
  2. 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)

    Login or Signup to reply.
  3. You might be looking for something already existing, for example:
    https://github.com/status-im/go-maven-resolver. Usage:

    $ echo commons-io:commons-io:2.4 | ./go-maven-resolver
    https://repo.maven.apache.org/maven2/commons-io/commons-io/2.4/commons-io-2.4.pom
    https://repo.maven.apache.org/maven2/org/apache/commons/commons-parent/25/commons-parent-25.pom
    https://repo.maven.apache.org/maven2/org/apache/apache/9/apache-9.pom
    

    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.

    Login or Signup to reply.
  4. 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:

    • Repository URL
    • groupId
    • artifactId
    • version

    The main repository is Maven Central. Its URL is https://repo1.maven.org/maven2/. Most libraries are
    available 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:

    <dependencies>
        <dependency>
          <groupId>com.parse.bolts</groupId>
          <artifactId>bolts-android</artifactId>
          <version>1.4.0</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.android.support</groupId>
          <artifactId>support-annotations</artifactId>
          <version>27.0.2</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.android.support</groupId>
          <artifactId>support-core-utils</artifactId>
          <version>27.0.2</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.android.installreferrer</groupId>
          <artifactId>installreferrer</artifactId>
          <version>1.1</version>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    

    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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search