Wrap several libraries into one

114 views Asked by At

What I am trying to approach is to wrap more than one library into one library (I guess it will be an AAR file)

The libraries that I want to wrap might be other (AARs/Jars/Gradle dependencies)

After digging into this issue I have reached some points (Please correct me if I am wrong)

1- Android studio prohibits creating an ARR from a library that already contains another AARs.

2- I have found this GitHub Project Fat AAR where you can include more than one AAR inside each other but I don't think it supports Kotlin DSL which I use in my library.

3- If I have an AAR that contains a gradle dependency, And I want to use the direct classes inside the embedded dependency from the application layer I should import it again in the application (And this is not an applicable solution in my case).

1

There are 1 answers

0
Maksym Moroz On

You should rely on Gradle dependency management to find and resolve transitive dependencies for you.

When you publish your library, it ships with a pom file that describes dependencies that have to be resolved. This is the right approach.

If for some reason you can't rely on Gradle dependency management, i.e. your library dependency is a artifact distributed locally, you have a few bad solutions. You can provide the dependency the same way you were provided, locally or, alternatively, if you are not interested in resources shipped with your library dependency you can use tools like aar2jar to extract the jar artifact from aar and then you can include that jar in your distribution. Note, this is the bad approach and you should avoid it if you can.