Setup
This section explains what to add to your Gradle build to use Koin. Pick your platform below, then follow the linked section of Gradle Setup. If you have not chosen a declaration style yet, read Choosing your style first: it decides whether you also need the Compiler Plugin.
What to install
| Platform | Artifacts | Setup |
|---|---|---|
| Kotlin/JVM | koin-core | Kotlin/JVM |
| Android | koin-android | Android |
| Android with Jetpack Compose | koin-android, koin-compose, koin-compose-viewmodel | Jetpack Compose |
| Compose Multiplatform | koin-compose, koin-compose-viewmodel | Compose Multiplatform |
| Kotlin Multiplatform | koin-core in commonMain | Kotlin Multiplatform |
| Ktor | koin-ktor, koin-logger-slf4j | Ktor |
| Tests | koin-test, koin-test-junit4 or koin-test-junit5 | Testing |
Recommended setup
For a new project:
- Koin BOM: import
io.insert-koin:koin-bomand declare Koin artifacts without versions, so they always match. See Gradle Setup. - Koin Compiler Plugin: apply the Gradle plugin
io.insert-koin.compiler.pluginto get the Compiler Plugin DSL or annotations, with compile-time checks. It needs Kotlin 2.3.20 or later. See Compiler Plugin Setup.
If you use the classic DSL only, step 1 is enough.
warning
The KSP processor koin-ksp-compiler is deprecated. Its setup is kept in KSP Processor Setup for existing projects only. New projects use the Compiler Plugin.
Versions
| Component | Current version | Kotlin |
|---|---|---|
Koin (all libraries, including koin-annotations) | 4.2.2 | Built with 2.3.20 |
| Koin Compiler Plugin | 1.2.1 | Verified on 2.3.20, 2.4.0, 2.4.10, 2.4.20 (needs Koin 4.2.0+) |
Latest published versions:
Older Koin lines:
| Koin | Kotlin | Compiler Plugin |
|---|---|---|
| 4.2.x | 2.3.20+ | Yes |
| 4.1.x | 2.1+ | No, KSP processor only |
| 4.0.x | 1.9+ | No, KSP processor only |
| 3.5.x | 1.8+ | No |
What changed between versions and how to upgrade is in Releases.
Related
- Gradle Setup: the BOM and every Koin artifact.
- Compiler Plugin Setup: install and configure the plugin.
- Choosing your style: which style needs what.
- Tutorials: a first app on each platform.
- Releases: versions and upgrade notes.