Skip to main content
Version: 3.1

Koin v2

Setup Koin for your project

Version

caution

Koin v2.x is in end of support. Please upgrade to latest Koin v3.x

koin_version = '2.2.3'

You can find all Koin packages on maven central.

Gradle

Check that you have the mavenCentral repository.

// Add Maven Central to your repositories if needed
repositories {
mavenCentral()
}

Dependencies

Pick one of your Koin dependency:

Gradle Plugin

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "io.insert-koin:koin-gradle-plugin:$koin_version"
}
}

apply plugin: 'koin'

Core features

// Koin for Kotlin
implementation "io.insert-koin:koin-core:$koin_version"
// Koin extended & experimental features
implementation "io.insert-koin:koin-core-ext:$koin_version"
// Koin for Unit tests
testImplementation "io.insert-koin:koin-test:$koin_version"
// Koin for Java developers is now part of core
// implementation "io.insert-koin:koin-java:$koin_version"

Android

// Koin for Android
implementation "io.insert-koin:koin-android:$koin_version"
// Koin Android Scope features
implementation "io.insert-koin:koin-android-scope:$koin_version"
// Koin Android ViewModel features
implementation "io.insert-koin:koin-android-viewmodel:$koin_version"
// Koin Android Experimental features
implementation "io.insert-koin:koin-android-ext:$koin_version"

AndroidX

// Koin AndroidX Scope features
implementation "io.insert-koin:koin-androidx-scope:$koin_version"
// Koin AndroidX ViewModel features
implementation "io.insert-koin:koin-androidx-viewmodel:$koin_version"
// Koin AndroidX Fragment features
implementation "io.insert-koin:koin-androidx-fragment:$koin_version"
// Koin AndroidX WorkManager
implementation "io.insert-koin:koin-androidx-workmanager:$koin_version"
// Koin AndroidX Jetpack Compose
implementation "io.insert-koin:koin-androidx-compose:$koin_version"
// Koin AndroidX Experimental features
implementation "io.insert-koin:koin-androidx-ext:$koin_version"

Ktor

// Koin for Ktor Kotlin
implementation "io.insert-koin:koin-ktor:$koin_version"