Incorrect value of app module dimen/color when using in dynamic-delivery module

Viewed 204

I have app module and one dynamic module named - "chat". I have a layout and fragment resides in chat module, in layout there is a android:textSize="@dimen/sp20" written. Dimen is defined in app module due to that it is showing incorrect text size when I run it. I debugged it, it is equal to 12sp (36 for xxhdpi device).

I tried to use dimen programtically but same result. (landing_page_toolbar_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(com.sendbird.R.dimen.sp20))) . Carefully used "R" from app module package.

When I define the same value in chat module, it works perfectly. But it is not feasible for our scenario. I have tons of string, dimens, color resources with multiple configurations written in app module. Please share feasible solution.

Attaching screenshot for better understanding.Reflection based result comparison

2 Answers

Can you try by updating your app module resources with the "app_sp20" prefix, it will be resolved mostly.

Common names are mostly overridden by SDKs/modules

Still, you face the problem then use reflection as the last option.

When a dynamic module is downloaded, it’s code and resources are placed at the app's internal storage. Maybe this storage has an inconsistent or outdated state (incl. cached resources from the app). If the problem occurs during depelopment / testing try to clear your app's internal storage.

Also make sure that you initialize SplitCompat correctly for your app and all activities / fragments of your dynamic module as described: here. Documentation is quite vague about what SplitCompat is actually doing but not initializing it correctly could also have impact on the access of app resources from dynamic modules.

Related