Create one aar from multi module library in android


I have the following modules in my aaplication





the module library_1 ‘has dependecy of library_2
build gradle library_1

dependencies {
api project(":library_2")

When I build the project I get the aar which I put in my app module

dependencies {
implementation files('libs/library_1-debug.aar')

Now when I run my app I get the exception java.lang.NoClassDefFoundError: Failed resolution of: Lcom/dinklo/library_2/LibraryB

The class LibraryB is defined in library_2 and being called from library_1

I am looking for a solution where I can get a single aar file for all the modules I have.


I ended up using third party library Fat-aar

In root build gradle

 classpath 'com.github.kezong:fat-aar:1.3.8'

In your library module

apply plugin: 'com.kezong.fat-aar'

embed project(path: ':lib-2', configuration: 'default')}

I have added a sample project on github will be usefol for others

Fat-arr Sample – Github

Answered By – WISHY

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published