Skip to content Skip to sidebar Skip to footer

Android Studio How To Package Single Aar From Multiple Library Projects?

I am building android library project, which has a dependency on another internal library project. I am wondering if there is a way to package a single AAR library, which already c

Solution 1:

There is no mechanism to combine library. It's a bit complicated as you probably want to control which dependencies get merged (for instance you probably don't want to include support-v4 in there). Also you'd need to merge the resources and Android manifest.

At this time there's no way to easily hack something, unless you are sure the resources have no conflicts between the two res folders (for instance you could have strings_a.xml in one lib and strings_b.xml in the other lib). This way you can just "merge" the two res folders by copying them both into the same location (as opposed to do a merge at the android res level).

For the Manifest it'd be more complicated, but doable with some custom code.

Providing a built-in mechanism for this is very low on our priority so don't expect it anytime soon.

Solution 2:

For the sake you have to upload each library as separately on maven and use its implementation in parent library modules till the main library module. Only then when you publish your main library on maven will include your all child dependencies.

Solution 3:

As far as we have only one option add aar as api dependency inside the module. For that we have to generate aar file and publish it to Maven and make it accessible by another module and consume it in app.

https://developer.android.com/studio/projects/android-library

As mentioned above android developer document.

The library module with source code is copied to your project, so you can actually edit the library code. If you want to maintain a single version of the library code, then this is probably not what you want and you should instead add the compiled AAR file as described above.

If there anything else we can do, please let us know by jot down in the command section.

Solution 4:

It is not supported

It is not recommended to include one library into another because it leads to a serious issues with managing versions and complexity of creating and supporting such solution.

You should stick to native approaches like dependency manager or rearchitect your codebase

[iOS Umbrella framework]

Post a Comment for "Android Studio How To Package Single Aar From Multiple Library Projects?"