Beyond Hilt's Built-In Scopes: Scope shared dependencies to the current screen
2025-11-20 , Sala 7

Modern Android apps normally follow the Single-Activity architecture with Compose Navigation, but as screens grow complex with multiple UI components and ViewModels, we hit a fundamental limitation: there's no clean way to share dependencies at the screen level. Built-in Hilt scopes are either too broad (@Singleton, causing state leakage) or too narrow (@ViewModelScoped, preventing sharing).

This talk introduces a custom Dagger component that solves this gap with screen-scoped dependency injection that matches the screen lifecycle.

Key Takeaways
- Understand Hilt's component hierarchy limitations
- Learn how to build custom Hilt components and manage their lifecycle
- Implement screen-scoped dependency injection with a practical example

Perfect for developers already comfortable with Hilt/Dagger dependency injection, who hit this architectural wall and only found hacky solutions to work around it.

Luca has been an Android Engineer for over a decade, between Italy and Japan, always striving for clean, scalable, and maintainable Android apps. He's excited to share practical solutions with the Android community that helped shape his journey so far.