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. ...