Skip to main content
Version: 4.2

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​

PlatformArtifactsSetup
Kotlin/JVMkoin-coreKotlin/JVM
Androidkoin-androidAndroid
Android with Jetpack Composekoin-android, koin-compose, koin-compose-viewmodelJetpack Compose
Compose Multiplatformkoin-compose, koin-compose-viewmodelCompose Multiplatform
Kotlin Multiplatformkoin-core in commonMainKotlin Multiplatform
Ktorkoin-ktor, koin-logger-slf4jKtor
Testskoin-test, koin-test-junit4 or koin-test-junit5Testing

For a new project:

  1. Koin BOM: import io.insert-koin:koin-bom and declare Koin artifacts without versions, so they always match. See Gradle Setup.
  2. Koin Compiler Plugin: apply the Gradle plugin io.insert-koin.compiler.plugin to 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​

ComponentCurrent versionKotlin
Koin (all libraries, including koin-annotations)4.2.2Built with 2.3.20
Koin Compiler Plugin1.2.1Verified on 2.3.20, 2.4.0, 2.4.10, 2.4.20 (needs Koin 4.2.0+)

Latest published versions:

  • Koin: Maven Central
  • Koin Compiler Plugin: Maven Central

Older Koin lines:

KoinKotlinCompiler Plugin
4.2.x2.3.20+Yes
4.1.x2.1+No, KSP processor only
4.0.x1.9+No, KSP processor only
3.5.x1.8+No

What changed between versions and how to upgrade is in Releases.