0Pricing
Android Academy · Lesson

Modules and Providers

Tell Hilt how to create dependencies.

Telling Hilt How to Build Things

Hilt can construct a class automatically if its constructor is annotated @Inject. But for interfaces or types you do not own, you must teach Hilt with a Module.

Constructor Injection

The simplest case: annotate the constructor and Hilt knows how to build it.

class Analytics @Inject constructor(
    private val api: ApiService
)

All lessons in this course

  1. Why Dependency Injection?
  2. Setting Up Hilt
  3. Modules and Providers
  4. Injecting into ViewModels
← Back to Android Academy