0PricingLogin
Jetpack Compose Academy · Lesson

Modules, @Provides & @Binds

Tell Hilt how to build your types.

When Constructor Injection Is Not Enough

You cannot add @Inject to a constructor you do not own, like a Retrofit or OkHttp instance. Hilt needs another way to learn how to build those.

Meet the Module

A module is a class that teaches Hilt how to create types it cannot construct on its own. Mark it with @Module to register it.

@Module
object NetworkModule { }

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