Hilt Basics
ARCHITECTURE › Dependency Injection
Drills Hilt setup, injection annotations, modules, qualifiers, ViewModels, and the Dagger it generates.
Hilt is the standard DI framework for Android, and interviewers use it to probe whether you understand dependency injection beyond memorizing annotations. Expect questions on setup (@HiltAndroidApp, @AndroidEntryPoint), how to provide bindings (@Inject vs @Module/@Provides/@Binds), scoping to component lifecycles, and how Hilt sits on top of Dagger. Strong answers connect each annotation to the generated component graph and compile-time validation.
What this covers
- Why DI matters: decoupling, testability, and letting Hilt manage object graphs instead of manual construction
- Core setup: @HiltAndroidApp on the Application and @AndroidEntryPoint on Activities/Fragments/Services to enable field injection
- Telling Hilt how to build types: @Inject constructors vs @Module with @Provides and @Binds, and when each applies
- Disambiguating same-type bindings with @Qualifier and using predefined @ApplicationContext / @ActivityContext
- @HiltViewModel plus hiltViewModel() in Compose, and the ViewModelComponent / SavedStateHandle behavior
- What Hilt generates: Dagger components per Android class, scopes, and compile-time graph validation
Study this topic
- Hilt Basics explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Hilt Basics interview questions and answers