neonDion
neonDion

Reputation: 2358

Impossible to ship .aar with dependencies?

I'm trying to create an Android library called MyLib.

The library depends on several other libraries and modules: A, B and C.

It seems that when my MyLib.aar is created that A, B and C are not included.

When I integrate my MyLib.aar in to an app I must set A, B and C as dependencies in the app's build.gradle. But I already set them as dependencies in the MyLib library project.

Is this the correct behavior?

Is there any way to package A, B and C with MyLib so that an app that depends on MyLib will not need to explicitly declare A, B and C as dependencies?

Upvotes: 1

Views: 352

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007484

So if I want to distribute MyLib to other developers and have them be able to resolve the dependencies in their build environments, then it sounds like a solution would be to create a public Maven repo holding the dependencies of MyLib and then the dev using the library would be able to resolve all dependencies. Am I understanding that correctly?

Generally speaking, yes.

The AAR itself, and its POM file, would be hosted by a repository, one that is visible to whatever developers need the AAR. That could be an in-house repository for a team, all the way up to something like Maven Central.

The dependencies of the AAR will then fall (hopefully) into two camps:

  1. Those that are already publicly-visible dependencies (e.g., out on Maven Central), which consumers of your AAR/POM will be able to pull down

  2. Those that are your own code, which you would then treat like the AAR itself, putting the dependency and its POM in the repo, so others can get at it when they consume the primary AAR from the repo

Upvotes: 1

Related Questions