Resources not found when adding a module as a dynamic feature on Android

Viewed 184

I have a base ai.application.resident and I added a new module as dynamic feature com.application.wearable

When creating a bundle, I get this error: app/base/build/intermediates/bundle_manifest/debug/AndroidManifest.xml:2282: AAPT: error: resource style/WearableTheme (aka ai.application.resident:style/WearableTheme) not found

There are also other resource errors in the bundle. It seems like the manifest is only looking for the resources in the base's package.

What is the proper solution for this? Do I have to move my themes in the base package?

Thank you

PS: This wearable app if my first android app. Please be understanding!

Thank you in advance.

1 Answers

Please provide more detail of your module arrangement, gradle files, and AndroidManifest.xml file(s).

If you are trying to reference resources or classes in a dynamic feature module from your top-level app, it is like you are trying to reach an object that is on the other side of a wall: the laws of physics don't allow it. Here in Android resource availability gravitates to the dynamic feature module within which the resource exists. Only through reflection could you reference them, but that approach is dangerous as the dynamic feature module won't always be there for your users in the wild.

I think you should look at Manifest Merging to hold your Wearable dynamic feature module's AndroidManifest content within the dynamic feature module (where the resources it wants to reference is available). If/when a user downloads your dynamic feature module, your app's package will be updated with the merged module.

Related