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?

2

There are 2 best solutions below

2
On

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.

1
On

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.