Android Tutorial #2: Dependency Injection with Hilt — Complete Guide

In the previous tutorial, you learned about Clean Architecture layers. But there is a problem — who connects everything together? Who creates the repository and gives it to the ViewModel? Who creates the database and gives it to the repository? You could wire everything manually. But with 10 ViewModels, 5 repositories, and 3 data sources, you will spend more time wiring than coding. Hilt solves this. You annotate your classes and Hilt connects everything automatically. It is Google’s recommended DI framework for Android. ...

July 4, 2026 · 9 min

Jetpack Compose Tutorial #14: Dependency Injection with Hilt

In the previous tutorials, we created databases and ViewModels manually. We wrote DatabaseProvider singletons. We passed dependencies by hand. It worked — but it doesn’t scale. When your app has 10 ViewModels, 5 repositories, 3 data sources, and a database — wiring everything manually becomes a nightmare. One missing connection and your app crashes. Hilt fixes this. You add annotations to your classes, and Hilt connects everything automatically. What is Dependency Injection? Dependency injection (DI) means: instead of a class creating its own dependencies, someone else provides them. ...

March 23, 2026 · 7 min