Skip to main content

Koin

All you need to setup Koin in your project

Current Versions

You can find all Koin packages on maven central.

Here are the current available versions:

  • koin-core - https://img.shields.io/maven-central/v/io.insert-koin/koin-core
  • koin-android - https://img.shields.io/maven-central/v/io.insert-koin/koin-android
  • koin-androidx-compose - https://img.shields.io/maven-central/v/io.insert-koin/koin-androidx-compose
  • koin-ktor - https://img.shields.io/maven-central/v/io.insert-koin/koin-core

Gradle Setup

Kotlin

Add koin-core dependency to your application:

dependencies {

compile "io.insert-koin:koin-core:$koin_version"
}

You are now ready to start Koin:

fun main() {

startKoin {
modules(...)
}
}

If you need testing capacity:

dependencies {
// Koin Test features
testImplementation "io.insert-koin:koin-test:$koin_version"
// Koin for JUnit 4
testImplementation "io.insert-koin:koin-test-junit4:$koin_version"
// Koin for JUnit 5
testImplementation "io.insert-koin:koin-test-junit5:$koin_version"
}
info

From now you can continue on Koin Tutorials to learn about using Koin: Kotlin App Tutorial

Android

Add koin-android dependency to your Android application:

dependencies {

implementation "io.insert-koin:koin-android:$koin_android_version"
}

You are now ready to start Koin in your Application class:

class MainApplication : Application(){
override fun onCreate() {
super.onCreate()

startKoin{
modules(appModule)
}
}
}

If you need extra features, add the following needed package:

dependencies {
// Java Compatibility
implementation "io.insert-koin:koin-android-compat:$koin_android_version"
// Jetpack WorkManager
implementation "io.insert-koin:koin-androidx-workmanager:$koin_android_version"
// Navigation Graph
implementation "io.insert-koin:koin-androidx-navigation:$koin_android_version"
}
info

From now you can continue on Koin Tutorials to learn about using Koin: Android App Tutorial

Android Jetpack Compose

dependencies {

implementation "io.insert-koin:koin-androidx-compose:$koin_android_compose_version"
}

You are now ready to start Koin in your Application class:

class MainApplication : Application(){
override fun onCreate() {
super.onCreate()

startKoin{
modules(appModule)
}
}
}
info

From now you can continue on Koin Tutorials to learn about using Koin: Android Compose App Tutorial

Kotlin Multiplatform

Add koin-core dependency to your multiplatform application, for shared Kotlin part:

dependencies {

compile "io.insert-koin:koin-core:$koin_version"
}
info

From now you can continue on Koin Tutorials to learn about using Koin: Kotlin Multiplatform App Tutorial

Ktor

Add koin-ktor dependency to your multiplatform application:

dependencies {
// Koin for Ktor
implementation "io.insert-koin:koin-ktor:$koin_ktor"
// SLF4J Logger
implementation "io.insert-koin:koin-logger-slf4j:$koin_ktor"
}

You are now ready to intall Koin feature into your Ktor application:

fun Application.main() {
install(Koin) {
slf4jLogger()
modules(appModule)
}
}
info

From now you can continue on Koin Tutorials to learn about using Koin: Ktor App Tutorial