0

I want to put a big AAR library ("crypteriumsdk") into a Dynamic Feature Module, which can be installed on-demand. But when I do that, it can't find its resources (theme):

resource style/CrypteriumTheme (aka com.crypter.cryptocyrrency:style/CrypteriumTheme) not found.

I also added tools:replace="android:theme" to application in main Manifest (app module).

What is wrong here?

enter image description here

enter image description here

settings.gradle:

include ':crypteriumsdk'
include ':wallet'
include ':app'

wallet.gradle:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(":app")
    implementation project(':crypteriumsdk') // added the library here
}
c0dehunter
  • 6,412
  • 16
  • 77
  • 139

1 Answers1

3

The Manifest gets merged too early for the actual theme implementation to be available on the user's device.

You can add this to your base module's styles.xml:

    <style name="CrypteriumTheme" />

This allows for the style resource id to be found at install time and for it to be overwritten once the module is available and launched.

See this sample for a working implementation.

Ben Weiss
  • 17,182
  • 6
  • 67
  • 87
  • Thanks, this works! Do you maybe know what I can do about resources with same name from 3rd party libraries? E.g. we use library A in our base (app) module, and then library B in dynamic feature module, and both libraries have some layout resource with same name. This causes error when trying to build a bundle: `Modules 'base' and 'dynamicfeature' contain entry 'res/layout/design_bottom_navigation_item.xml' with different content.`. I know it's offtopic for this question, but would highly appreciate your experience on this :) – c0dehunter Aug 15 '20 at 13:55
  • Here is a question regarding this: https://stackoverflow.com/questions/61702779/getting-this-error-modules-base-and-modulea-contain-entry-res-drawable-xyz – c0dehunter Aug 17 '20 at 02:32
  • Thanks for bringing it up. I added an [answer](https://stackoverflow.com/questions/61702779/getting-this-error-modules-base-and-modulea-contain-entry-res-drawable-xyz/63451083#63451083) to the question. – Ben Weiss Aug 17 '20 at 13:07