Creating a dependency library in android

I created the "LibA" library, which has dependencies on many third-party libraries such as RecyclerView, EventBus, etc. When I tried to include it in another project as aar, the library was included successfully, but the dependencies did not come in aar.

Q1 . How to include dependencies in LibA, so that when some other project includes this library, it should not worry about the internal dependencies of my library.

Q2 How does gradle manage library dependencies, does it load all protected objects at once or the first checks that are already available in the main project?

Q3 When someone includes a library from jcenter, does it support all the dependencies?

Any help would be greatly appreciated. :)

+5
source share
1 answer

The aar file does not contain nested (or transitive ) dependencies and does not have a pom file that describes the dependencies used by the library.

This means that if you import the aar file using flatDir relay, you must specify the dependencies in your project as well.

Q1 How to enable dependencies in LibA, so that when some other project includes this library, it should not worry about the internal dependencies of my library.

You should use the maven repository (you must publish the library in a private or public maven repository), you will not have the same problem.
In this case, gradle loads the dependencies using the pom file, which will contain the list of dependencies.

Q2 How does gradle manage library dependencies, does it load all the individual blocks or first check which are already available in the main project?

Gradle handles the dependencies for you. It does not add the same dependency twice or more.

Q3 When someone includes a library from jcenter, does it support all the dependencies?

As mentioned earlier, in this case, the dependency has a pom file that describes all the nested dependencies. gradle loads it automatically.

+3
source

All Articles