Member-only story

Android Hilt Simplified

Sachin Kumar
2 min readDec 6, 2020

--

In this article we are going to understand the Android Hilt Dependency Framework in a simple manner using the important annotations which are highly required to implement DI in Android app development.

Let’s first try to understand what exactly Hilt in Android:

  • It is a dependency framework which has been built on top of Dagger.
  • It provides abstraction, less boiler plate codes.
  • It provides internal Dagger component out of the box for application, activities, fragments, views, etc.
  • It supports AndroidX libraries such as ViewModels, WorkManagers out of the box.

This framework works based on annotations as well like Dagger. Let’s use each of them to manage the dependencies in our code, for simplicity we are trying to implement field injection dependency.

For using Hilt first we have to implement our own Application class and make use of @HiltAndroidApp annotation:

It initiates the process of all the injections going on in our application.

--

--

Sachin Kumar
Sachin Kumar

Written by Sachin Kumar

Senior Java Backend Dev | Expertise in Java Microservices, Spring Boot Framework & Android apps development.

No responses yet