A plugin that visualizes Dagger/Hilt dependency graphs.
It outputs SVG or DOT (Graphviz) format without requiring any additional tools.
Example: https://github.com/android/architecture-samples
This plugin is implemented solely in Kotlin, with minimal external dependencies.
It renders the graph following the Hilt scope component hierarchy.
It uses the Dagger compiler's SPI (Service Provider Interface)
to capture the binding graph at compile time, generate a DOT file, and convert it to SVG.
// settings.gradle.kts
pluginManagement {
repositories {
mavenCentral() // required!!
}
}
dependencyResolutionManagement {
repositories {
mavenCentral() // required!!
}
}Apply the plugin to the Android app module whose graph you want to output.
// app/build.gradle.kts
plugins {
id("com.android.application")
id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
id("io.github.fairydevicesrd.hiltblueprint") version "0.1.0" // here!!
}When using libs.versions.toml:
[versions]
hiltBlueprint = "0.1.0"
[plugins]
hilt-blueprint = { id = "io.github.fairydevicesrd.hiltblueprint", version.ref = "hiltBlueprint" }# Output as SVG (recommended — zoomable in a browser, no Graphviz installation required)
./gradlew :app:generateHiltBlueprintSvg
# Output DOT only
./gradlew :app:generateHiltBlueprintDotOutput location: {module}/build/reports/hilt-blueprint/{ApplicationName}.svg / .dot
Note
After clean, if the DOT file is missing but the build cache hits, Hilt compilation may be skipped and the DOT file will not be regenerated. In that case, add --rerun-tasks.
./gradlew :app:generateHiltBlueprintSvg --rerun-tasks| Color | Meaning |
|---|---|
Blue (#E3F2FD) |
@Provides |
Orange (#FFF3E0) |
@Binds |
Green (#E8F5E9) |
@Inject constructor |
Gray (#F5F5F5) |
Others (multibinding, etc.) |
- Dagger / Hilt: 2.48 or later
- KSP: 2.1.10-1.0.29 or later
- Gradle: 8.0 or later
MIT License