简体   繁体   中英

Is it possible for a dynamic feature module to depend on another dynamic feature module?

I have a modular project which contains a base module (base) and two others modules (A & B) which depends on base. It works.

Now, I want to add a new module C which depends on B and base.

So I create a dynamic feature module C and add this in its build.gradle :

implementation project(':base')
implementation project(':B')

But C can't access B resources. For example, if I put some dimensions in the dimens.xml file of B, C can't access these dimensions. I have a "Android resource linking failed" error.

Do I need to add more code than the "implementation project" in order to make this works ?

If this error is coming from your xml, then unfortunately, xml is limited in this way. You are recommended to place your resources in your base and/or moduleC itself.

However, if you're doing it in runtime, you can point to moduleB's dimens resources by using com.sample.moduleb.R.dimen.some_margin

Regardless, it's recommended to either have your resources in the base module or the calling module itself, because what if the other module isn't instant-installed yet? (which is an entirely likely scenario for instant apps)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM