0Pricing
Android Academy · Lesson

Why Dependency Injection?

Make code testable and modular.

What Is Dependency Injection?

Dependency Injection (DI) means giving an object the things it needs from the outside, rather than letting it create them itself.

The Problem: Hard Dependencies

When a class builds its own dependencies, it becomes tightly coupled and hard to change or test.

class UserViewModel {
    private val repo = UserRepository(
        ApiClient(), AppDatabase.get()
    ) // tightly coupled
}

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