[SOLVED] Create one aar from multi module library in android

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under
CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.


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 useful for others

Fat-arr Sample – Github

Answered By – WISHY

people found this article helpful. What about you?