How to import an .aar library file in a library module and export as single library?

Viewed 1073

I have an .aar library (libA.aar) file and a library module. The .aar file added to library module in dependencies section (at library module build.gradle)(libB.aar):

implementation files('libs/libA.aar')

When I export this library as an .aar file (libB.aar) the imported library (libA.aar) not found on exported file.

How can I import that .aar file in a library and having that in exported file? Is need to use offline Maven repository?

I need a fat library with all of dependency inside that as an .aar file.

3 Answers

You have to separately include[copy/paste] all the used .aar libraries into the integrating application as well.

Add your .aar file in src -> main -> libs folder

Adding .aar file


Add path in your build.gradle(Project) file

allprojects {
    repositories {
        google()
        jcenter()
        flatDir { //Add this code
            dirs 'src/main/libs'
        }
    }
}

Add implementation code in your build.gradle(app) file

dependencies {
    implementation(name: 'nameOfAARFile', ext: 'aar')
}
Related