2

moduleA is a dynamic feature module with dependency which is an aar lib.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':app')
    implementation(name:'lib', ext:'aar')
}

It builds successful and installs on the emulator but whenever I want to create an app-bundle, I get the following error:

Modules 'base' and 'moduleA' contain entry 'res/drawable/xyz.xml' with different content.

If I should rename xyz.xml in the app module, I get error:

../moduleA/build/intermediates/metadata_feature_manifest/fullDebug/processFullDebugManifest/metadata-feature/AndroidManifest.xml:61:13-63:50: AAPT: error: resource drawable/xyz (aka my.app.main.drawable/xyz) not found.

This is one of the issues highlighted in Plaid's modularization article.

To solve it, I had to create an empty xyz.xml in the app module, but when creating an app-bundle, I get the error:

Modules 'base' and 'moduleA' contain entry 'res/drawable/xyz.xml' with different content.

What is the problem and how can it be solved?

Chike
  • 23
  • 1
  • 5
  • 1
    Were you able to solve this? I have an exact problem. I want to put AAR as a dependency in a module but got this issue. – c0dehunter Aug 17 '20 at 02:39

2 Answers2

6

As you removed base/.../xyz.xml you won't be able to access it from your base module (app).
If you rename base/.../xyz.xml to base/.../zzz.xml you will have to change references to it as well.

If you don't access base/.../xyz.xml in your base module at all, you can remove the file. Then you'll have to make sure all your imports are pointing not to base.R.drawable.xyz but to feature.R.drawable.xyz.

If both files actually could be the same, remove feature/.../xyz.xml and make sure to only import base.R.drawable.xyz.

If both files have to be different, rename either one and make sure to get your imports correct.

Ben Weiss
  • 17,182
  • 6
  • 67
  • 87
  • 2
    What about if two 3rd party libraries use the same resource names? In my case, library A in base module (referenced and required by base module), and AAR library in dynamic feature module have a resource with the same name. Obviously, renaming is not an option since they are libraries. Moving AAR to base module also not possible, because its size is main reason why we put it in a separate, on-demand, module. Problematic resources are some animations: `Modules 'base' and 'dynamicfeature' contain entry 'res/anim/shake.xml' with different content.` – c0dehunter Aug 18 '20 at 02:06
1

Both modules base and moduleA seem to depend on the same AAR.

Instead, put the AAR as a dependency of module base only. moduleA should be able to find the resource through a transitive dependency of module base.

Pierre
  • 15,865
  • 4
  • 36
  • 50
  • 3
    Thanks for the suggestion, but if I include it into base only, won't it be part of the base apk? The goal is to use the aar lib inside moduleA only. So as to reduce the initial apk file size. – Chike May 11 '20 at 11:04
  • I see. Can you find out what dependency the `res/drawable/xyz.xml` is coming from in your base module then? It seems that directly or indirectly, you either depend on the same AAR, or you depend on a library which pulls a resource with the same name. – Pierre May 11 '20 at 21:06