Hilt
When we use Dagger in an Android application, there is a bit of boilerplate code we are forced to write. Some of it is around dealing with the lifecycles of objects linked with Activities and Fragments, which leads us to create subcomponents; other parts are around the usage of ViewModels.
An attempt to simplify Dagger for Android was made with the Dagger-Android library, but later on, a new library was developed on top of Dagger called Hilt. This library simplifies much of the Dagger usage through the usage of new annotations, which leads to more boilerplate code that can be generated.
To use Hilt in a project, we will need the following:
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'com.google.dagger.hilt.android'
Or depending on how your project uses Gradle, you might need to use the following:
plugins { … id 'kotlin...