The aar dependency is not like the maven / ivy dependency in that there is no transitive dependency in the pom or xml file associated with it. When you add aar dependency, gradle has no way to know which transitive dependencies are retrieved.
Common practice in the Android world seems to be to explicitly add transitive dependencies to your application that uses aar. This can be a cumbersome and heterogeneous defeat of a point in a dependency management system.
There are several ways:
1. The android-maven plugin
There is a third-party gradle plugin that allows you to publish the aar file to the local maven repository along with a valid pom file.
2. The maven-publish plugin
You use the standard maven-publish plugin to publish aar for the maven repo, but you need to build the pom dependencies yourself. For instance:
publications { maven(MavenPublication) { groupId 'com.example' //You can either define these here or get them from project conf elsewhere artifactId 'example' version '0.0.1-SNAPSHOT' artifact "$buildDir/outputs/aar/app-release.aar" //aar artifact you want to publish //generate pom nodes for dependencies pom.withXml { def dependenciesNode = asNode().appendNode('dependencies') configurations.compile.allDependencies.each { dependency -> def dependencyNode = dependenciesNode.appendNode('dependency') dependencyNode.appendNode('groupId', dependency.group) dependencyNode.appendNode('artifactId', dependency.name) dependencyNode.appendNode('version', dependency.version) } } } }
In both cases, when aar + pom is available in the maven repository, you can use it in your application as follows:
compile ('com.example:example: 0.0.1-SNAPSHOT@aar '){transitive=true}
(I'm not quite sure how transients work if you add the dependency as compile project(:mylib) . I will update this answer soon for this case)
source share