3

I have a module in my app that acts as a dynamic feature.

This dynamic feature module uses a third party library where this third party library has in its AndroidManifest an Activity that uses a custom theme.

With the described configurations, the app compiles fine, but when I try to run it, it throws an error saying that the resource of that Activity's theme could not be found.

The error looks like this:

AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"/Users/my_user/Documents/MyProject/App/AppName/build/intermediates/metadata_feature_manifest/debug/processDebugManifest/metadata-feature/AndroidManifest.xml","position":{"startLine":40,"startColumn":8,"endLine":45,"endColumn":54}}],"original":"/Users/my_user/Documents/MyProject/App/AppName/build/intermediates/metadata_feature_manifest/debug/processDebugManifest/metadata-feature/AndroidManifest.xml:41:9-46:55: AAPT: error: resource style/CustomTheme (aka com.my.project.domain:style/CustomTheme) not found.\n ","tool":"AAPT"}

* What went wrong: Execution failed for task ':app:processDebugResources'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Android resource linking failed /Users/my_user/Documents/MyProject/App/AppName/build/intermediates/metadata_feature_manifest/debug/processDebugManifest/metadata-feature/AndroidManifest.xml:41:9-46:55: AAPT: error: resource style/CustomTheme (aka com.my.project.domain:style/CustomTheme) not found.

I think that that problem is related to the following issue described by Google:

In a dynamic feature module’s manifest, you should not reference resources that don’t exist in the base module. That’s because, when Google Play generates your app’s base APK, it merges manifests for all modules into that of the base APK. So, resource linking breaks if the base APK’s manifest references resources that don’t exist in the base APK.

Reference: https://developer.android.com/guide/app-bundle/


How can one make that project run, if the third party library is not open to be modified?

Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61

1 Answers1

2

A work around to fix the mentioned problem is actually pretty simple (misleading and not good looking though).

For example, if the log complains about a style named CustomTheme and a string name custom_string that could not be found, all you have to do is create that style and string resource, empty, in your base module.

../app/src/main/res/values/styles.xml

<resources ...>
...

<style name="CustomTheme" />

</resources>

../app/src/main/res/values/strings.xml

<resources ...>
...

<string name="custom_string" />

<resources />
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61