We have created a demand dynamic module, this module just have the functionality of printing the data through a thermal printer, it doesn't have any activity. We need to access the classes and functions of this on demand module in our base code. Is it possible? if yes how can we access the code of the dynamic module in our base app after installing the dynamic module.
2
-
What is a "dynamic module" for you? In Android Studio a Module is just a library which provides Classes and Resources and can be accessed as usual: packagename.class.inner_class.methodemandt– emandt2021-04-06 08:43:04 +00:00Commented Apr 6, 2021 at 8:43
-
@emandt dynamic modules are very different than adding a library. That's true that they are a library at the end of the day but this library is loaded and added to the codebase on runtime, not on compile time. So you can not access the classes or resources using the method you mentionedWaqas Younis– Waqas Younis2023-10-12 22:29:00 +00:00Commented Oct 12, 2023 at 22:29
Add a comment
|
1 Answer
Code defined in on-demand module is not accessible from the main module, because it doesn't have on-demand module as a usual dependency. Although it is possible to access the code using reflection or dependency injection.
More info on the subject can be found here: https://medium.com/androiddevelopers/patterns-for-accessing-code-from-dynamic-feature-modules-7e5dca6f9123