Packaging Android AAR that has dependencies

By : dors
Source: Stackoverflow.com
Question!

I want to package my library as an aar.

The library has several dependencies (universal image loader, ORMLite, guava...)

It also has a dependency for another library that I wrote (call it 'library B').

I have 2 questions:

  1. Will everyone who will use my library need to add dependencies according to the library's dependencies (universal image loader, ORMLite, guava...)
  2. Do I need to create a separate aar for 'library B', and have users of my lib have a separate dependency for it?
By : dors


Answers
Will everyone who will use my library need to add dependencies according to the library's dependencies (universal image loader, ORMLite, guava...)

Not if you are distributing your AAR as an artifact in a repository with appropriate metadata (e.g., Maven-style POM file). The metadata will point to your dependencies, and build systems (e.g., Gradle) will pull in the dependencies.

Do I need to create a separate aar for 'library B'

Yes, otherwise nobody will have access to it, unless you eliminate it and fold its code into your first library.

and have users of my lib have a separate dependency for it?

See above for setting up dependencies.



You don not need do that,and you only do the next: if you aar libray have thirty dependencies: you should make others use your aar library in the way: for example:

compile('com.android:com.android.download:1.3')

or

compile('com.android:com.android.download:[email protected]'){
       transitive = true
}

if your aar libray have not thirty dependencies:

compile('com.android:com.android.download:[email protected]')

In a word:@aar have conflict with the default vault of transitive

By : FengYi Ya


This video can help you solving your question :)
By: admin