Designing Jetpack Compose Architecture for a Gradual Transition from Fragments on Android
Article Summary
Turo's Android team faced a challenge: how to adopt Jetpack Compose without rewriting their entire fragment-based app overnight.
Staff Engineer Pavlo Stavytskyi shares how Turo designed an architecture that lets developers write pure Compose code while maintaining seamless compatibility with legacy fragments. The solution uses code generation and abstraction layers to hide complexity.
Key Takeaways
- Single @UiEntry annotation generates fragment wrappers automatically for compatibility
- navigateTo() function abstracts all four navigation scenarios under one API
- Destinations concept eliminates reflection based navigation boilerplate code
- KSP generates factories injected via Dagger for type safe routing
- Dynamic NavHost destinations survive configuration changes with rememberSaveable
Critical Insight
Turo built a migration path where engineers write pure Compose code while code generation handles all fragment compatibility automatically.