Search code examples
androidgradleandroid-gradle-pluginaarmopub

Does including a AAR from jCenter also include its dependencies?


I have integrated the MoPub SDK into a new Android app, using the simplest method, that is adding a dependency to my main module's build.gradle (as instructed in MoPub integration guide):

repositories {
    jcenter()
}

dependencies {
    compile('com.mopub:mopub-sdk:4.1.0@aar') {
        transitive = true
    }
}

The guide mentions that several dependencies are required by the MoPub SDK:

Requirements and Dependencies

  • android-support-v4.jar, r22
  • android-support-annotations.jar, r22
  • android-support-v7-recyclerview.jar, r22
  • MoPub Volley Library (mopub-volley-1.1.0.jar - available on JCenter)

Should I add these dependencies myself, or is it handled by the Gradle dependency management system?


Solution

  • These are called Transitive dependencies and Gradle retrieves them automatically (assuming one specifies transitive=true as you have in the question)

    They are specified in the mopub-sdk pom file which is part of the information included in the library repo.

    You can check the file and you will find:

      <dependencies>
        <dependency>
          <groupId>com.google.android.exoplayer</groupId>
          <artifactId>exoplayer</artifactId>
          <version>r1.4.2</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.android.support</groupId>
          <artifactId>support-annotations</artifactId>
          <version>22.2.0</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.android.support</groupId>
          <artifactId>support-v4</artifactId>
          <version>22.2.0</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.android.support</groupId>
          <artifactId>recyclerview-v7</artifactId>
          <version>22.2.0</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.mopub.volley</groupId>
          <artifactId>mopub-volley</artifactId>
          <version>1.1.0</version>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    

    One twist is that the google support library dependencies are not available on JCenter() and you must install them separately using the Android SDK manager. Once they are installed locally, Gradle can find them in a local repository that the Android SDK sets up for this purpose.