Access Resources In Dynamic Feature Module of App Bundle

Viewed 1603

My usage scenario is a bit complicated.

In the dynamic form, I only have some views and resources. Those views should have access to those resources. In my base module, I will use these views from the activity of a basic module. Both my application and activity replace the attachBaseContext method.

But when I download and install the dynamic form, my views can not access resources using the task context. However, resources are accessible from applicationContext.

I do not understand how SplitCompat works. So the classes and resources loaded by the dynamic module connect only to applicationContext?

2 Answers

This problem is probably caused by an Android Studio bug. Clean the project and invalidate the cache, or build the project again.

You can take a look at how Dynamic Features are implemented in this sample.

There's sample code on how to open some resources, located in a dynamic module, from the base module.

Plus, the samples includes others dynamic modules with activities in implemented in Java/Kotlin and native.

Related