0Pricing
Android Academy · Lesson

Setting Up Hilt

Add Hilt and the application component.

Adding Hilt to a Project

Hilt needs a Gradle plugin and dependencies, plus an annotation processor (KSP or kapt). Setup is one-time per project.

Gradle Plugin

Apply the Hilt plugin in your module build file alongside KSP.

// module build.gradle.kts
plugins {
    id("com.google.dagger.hilt.android")
    id("com.google.devtools.ksp")
}

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