Include external module in android aar library

I have a fairly simple android library file build.gradle

(unnecessary parts removed),

apply plugin: 'com.android.library'

repositories {
    maven { url 'https://dl.bintray.com/alexeydanilov/maven' }
}

dependencies {
    compile 'com.danikula:videocache:1.0.1'
}

      

And I would like to be able to create an Android library .aar

that has all the files I want in it, but also all the files that come out of the external module videocache

.

I've tried many different methods to try and achieve this (another project, changing the "transient" settings, trying "export = true"), but they all failed and I'm not sure what else I can try.

If I download the original .jar file, write it to the libs, add the required bits to the settings file, it will drop correctly in .aar

, but I cannot find a way to do it using external module links like this.

+3


source to share


1 answer


First of all, it is not recommended to include an external library in the aar file. The previous answer for this can be found here :

I quoted the text as below:

Using the artifact will not include it in the aar. The whole point of using remote artifacts is not to rely on jars, but on an artifact so that a project using your "aar" can resolve all of its dependency graph, find duplicates, resolve conflicts, etc.

If you publish your "aar" to Maven, the artifact POM will contain dependencies. If you are using it from a multi-project setup, the "aar" generation project will push these dependencies to projects by referencing it.

For local jars, because these are not ways of knowing that the jar file we have to package it locally, but it really is not something you should use if you are going to push "aar" to the artifact repository.

So, if you want to include and use your "aar" lib from the remote repo, you can publish it first and then add this line to your dependencies:

compile 'Replace with the link to your lib'

      



If you want to use the "aar" file from your local location, there is also a less perfect but workable way to include all external libraries that just copy this line:

compile 'com.danikula:videocache:1.0.1'

      

for dependencies in the project that your lib is using. But this is not recommended anyway.

Hope my answer helps you.

0


source







All Articles