Robinhood Jin Cao Jul 22, 2019

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

Critical Insight

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.

The debug implementation includes a clever trick that lets engineers work on one feature while completely ignoring the rest of the app.

About This Article

Problem

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.

Solution

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.

Impact

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.