Android Inter-Module Navigation with Dagger
Article Summary
Robinhood's Android team cracked a tough modularization puzzle: how do you navigate between completely decoupled feature modules without creating dependencies?
Jin Cao from Robinhood Engineering shares their solution for inter-module navigation using Dagger's multibinding capabilities. This follow-up to their modularization story tackles the practical challenge of communication between independent feature modules while maintaining compile-time safety and fast build times.
Key Takeaways
- Uses Dagger multibinding to create navigation map without cross-module dependencies
- IntentKey classes provide compile-time safety for navigation arguments
- Debug builds gracefully handle missing modules to enable selective loading
- Developers can unload unused modules for faster builds without crashes
- Pattern works for activities, fragments, and views across independent modules
Robinhood built a type-safe navigation system that lets developers work on isolated feature modules with faster build times while maintaining the ability to navigate between any part of the app.
About This Article
Robinhood's Android app is split into feature modules that need to talk to each other, but they can't have direct dependencies on one another. Without a solution, navigation breaks or the modules end up tightly coupled, which defeats the whole point of splitting them up.
Jin Cao's team used Dagger multibinding to build a Map<IntentKey, IntentResolver>. Each feature module registers its own navigation resolvers into this map. This lets modules navigate across boundaries in a type-safe way through a shared lib-navigation contract.
Developers can now disable individual Gradle feature modules during development to speed up builds. The app doesn't crash when a module is missing. Debug builds just return empty intents as a fallback when an IntentKey can't be resolved.