4

I have an android library distributed in aar format. It weight 300kb. I want to create another library and also in aar format, where first library in dependencies. But result library weight is 30kb, so obviously it does not not include first library.

I tried to add first library using flatDir:

repositories {
    flatDir {
        dirs 'libs'
    }
}
dependencies {
    compile(name:'mylib-1.0', ext:'aar')
}

And publish to mavenLocal using maven-publish:

repositories {
    mavenLocal()
}
dependencies {
    compile 'com.mylib:mylib:1.0.0@aar'
}

but still it does not include to result aar.

How to include my first aar to result aar?

anber
  • 3,463
  • 6
  • 39
  • 68

1 Answers1

4

The best way to achieve it is to distribute the aar with a maven repo.

The aar file doesn't contain the transitive dependencies and doesn't have a pom file which describes the dependencies used by the library.
It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.

Using a maven repository you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 2
    Sorry, but I don't see there answer to my question there. I want that dependencies will be packed in result aar. How to do this? About `maven repository` I also did not get it. What should I do? I already use local maven repository and have the same issue. – anber May 30 '16 at 13:27
  • @anber As I know there is no automatic way to include an aar inside another one. If you are using a local maven, you should check the pom file.Inside you should have the dependency witht the other lib (aar). – Gabriele Mariotti May 30 '16 at 13:28