Skillshub android-di

Standards for Hilt Setup, Scoping, and Modules. Use when setting up Hilt dependency injection, component scoping, or modules in Android. (triggers: **/*Module.kt, **/*Component.kt, @HiltAndroidApp, @Inject, @Provides, @Binds)

install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/android-di" ~/.claude/skills/comeonoliver-skillshub-android-di && rm -rf "$T"
manifest: skills/HoangNguyen0403/agent-skills-standard/android-di/SKILL.md
source content

Android Dependency Injection (Hilt)

Priority: P0

Implementation Guidelines

Setup

  • App: Must annotate
    Application
    class with
    @HiltAndroidApp
    .
  • Entries: Annotate Activities/Fragments with
    @AndroidEntryPoint
    .

Modules

  • Binding: Use
    @Binds
    (abstract class) over
    @Provides
    when possible (smaller generated code).
  • InstallIn: Be explicit (
    SingletonComponent
    ,
    ViewModelComponent
    ).

Construction

  • Constructor Injection: Prefer over Field Injection (
    @Inject constructor(...)
    ).
  • Assisted Injection: Use for runtime parameters (
    @AssistedInject
    ).

Anti-Patterns

  • No Manual Dagger Components: Use Hilt — it generates all the wiring.
  • No Field Injection in Logic: Use constructor injection; field injection only in Android components.

References