Hilt Scopes & Components
ARCHITECTURE › Dependency Injection
Drills Hilt's component hierarchy, scope annotations, lifecycle mapping, and scoping pitfalls.
Hilt scoping is a staple of Android DI interviews because misusing scopes is the most common source of memory leaks and stale state in real apps. Interviewers test whether you can name each component, match it to its scope annotation and lifecycle, and reason about when a binding should be scoped versus unscoped. Expect questions probing why a wrongly scoped dependency leaks an Activity or shares state incorrectly across ViewModels.
What this covers
- Map each Hilt component to its scope annotation and the lifecycle it tracks
- Explain that unscoped bindings produce a fresh instance on every request
- Know that @Singleton lives for the app and @ActivityRetainedScoped survives configuration changes
- Distinguish @ViewModelScoped (per-ViewModel) from sharing across ViewModels
- Reason about the component hierarchy and which child components can access a binding
- Identify scoping pitfalls: leaking an Activity/Context by scoping it too widely
Study this topic
- Hilt Scopes & Components explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Hilt Scopes & Components interview questions and answers