0PricingLogin
Jetpack Compose Academy · Lesson

Why DI: Testable, Decoupled Code

See the problems Hilt solves.

What Is Dependency Injection?

Dependency injection means a class receives the objects it needs from the outside, instead of building them itself. Less wiring, more focus. 🔌

The Problem: new Everywhere

When a class calls new on its own dependencies, it gets locked to those exact types. Changing one thing forces you to edit many files.

class Repo {
    private val api = ApiService() // hard-wired
}

All lessons in this course

  1. Why DI: Testable, Decoupled Code
  2. Modules, @Provides & @Binds
  3. hiltViewModel & @HiltViewModel
  4. Scopes & Component Lifetimes
← Back to Jetpack Compose Academy