Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AAR not including module's resources

I have an Android library that is composed of 2 modules :

Project Root
+-- moduleA
|   +-- src
|   \-- build.gradle
|
+-- moduleB
|   +-- src
|   \-- build.gradle
|
+-- build.gradle
+-- settings.gradle

settings.gradle

include ':moduleB', 'moduleA'

moduleA/build.gradle

apply plugin: 'com.android.library'
...
dependencies {
    compile project(':moduleB')
}

moduleB/build.gradle

apply plugin: 'com.android.library'
...

When I try to use the AAR generated by gradle, the moduleB's resources are not included. I tried to push both AARs to maven local but same result.

If I change moduleA's type to application instead of library, the generated APK includes the correct resources.

What should I do so I can get an AAR that contains both modules resources?

like image 481
gdelente Avatar asked May 31 '26 03:05

gdelente


1 Answers

That is by design.

You have 2 options:

  1. publish both modules as AAR libraries (using something like this: https://github.com/dcendents/android-maven-gradle-plugin). This way, LibraryA will mark a dependency on LibraryB and import it, including resources using classical methods.

  2. build a fat AAR (using something like this: https://github.com/adwiv/android-fat-aar). This is basically what you were expecting to happen.

like image 178
Mircea Nistor Avatar answered Jun 01 '26 17:06

Mircea Nistor