Architect an Android app to support dynamic feature modules.
Instruction: Explain the architectural considerations and steps required to modify an existing monolithic Android application to support dynamic feature modules using the Android App Bundle.
Updated
Official answer
Start with a dependency and user-journey map. Choose one substantial optional feature, such as a document editor, whose absence does not prevent sign-in, navigation or essential tasks. Measure its size and usage before deciding that delivery complexity is justified.
First establish a clean module boundary in the monolith: stable entry points, shared domain contracts and resources with intentional ownership. Move only necessary shared code to common/base dependencies. The dynamic feature depends on the base; the base must not directly require optional classes before installation or create a cyclic dependency. Avoid copying the whole monolith into a shared module and calling the result modular.
Configure the app bundle, base dynamicFeatures list, feature plugin/base dependency and distribution manifest. Add a base-owned navigation gate that checks installation, requests delivery, reports progress/confirmation/failure and enters the feature only when available. Persist enough navigation intent to recover after recreation without repeating the user's business action.
Plan data-schema compatibility, permissions, analytics and dependency injection across the boundary. Features share the app's identity/version and are not separately updatable services. Removal is not an arbitrary immediate class-unloading mechanism; defer uninstall only when permitted and when retained data/dependencies remain coherent.
Roll out one feature, test installed/absent/offline/cancelled/recreated flows and use Play-supported testing in addition to local bundle tools. Keep an essential-task fallback. Compare initial bytes and time-to-first-use against installation failures, ongoing complexity and task completion before extracting more features.
Play Feature Delivery, On-demand delivery, Android modularization