What’s New

Koin

Frameworks & Libraries

A pragmatic dependency injection framework for Kotlin.

Latest 4.2.2 · by KotzillaWebsiteInsertKoinIO/koin

Changelog

4.2.2

Koin 4.2.2

Added 2
  • tvOS targets for koin-core-viewmodel (tvosArm64, tvosX64, tvosSimulatorArm64)
  • Consumer R8/ProGuard rules in Android and ViewModel artifacts with accompanying guide
Changed 1
  • bind() and binds() now register secondary types in O(1) instead of quadratic time
Fixed 6
  • Stacked params no longer shadow qualified dependencies in resolver
  • Root factory no longer resolves its scoped dependencies from _root_
  • viewModelScopeFactory scope is now linked to its parent
  • Tolerate non-String environment properties without ClassCastException
  • Unique Ktor request-scope ids under concurrency
  • Provide actionable errors for SavedStateHandle and viewModelScope without proper configuration

Maintenance release for the 4.2.x line — resolver regression fixes from the 4.2.0 CoreResolverV2 rewrite, ViewModel/scope fixes, a Ktor request-scope fix, plus new tvOS support and an R8/ProGuard guide.

Anyone hitting resolver issues on 4.2.0/4.2.1 should upgrade to 4.2.2.

Bug Fixes
  • Stacked params no longer shadow qualified dependencies (#2370, #2408) — A value passed via parametersOf could be returned for a get(named(...)) request of the same type, shadowing the qualified definition. Qualified lookups are now registry-only and never read the parameter stack — parameters carry no qualifier, so they can't satisfy a qualified request.

  • Root factory no longer resolves its scoped dependencies from _root_ (#2379) — When a non-single factory defined in the root scope was resolved from a child scope, CoreResolverV2 resolved its scoped dependencies against _root_ instead of the requesting scope. Linked-scope resolution now runs the factory against the requesting scope (single instances keep their root-bound semantics, preserving #2325).

  • viewModelScopeFactory scope is linked to its parent (#2299) — A ViewModel scope created via viewModelScopeFactory() was not linked to the originating scope, so dependencies declared in the parent couldn't be resolved. The created scope is now linked to its parent (except when the parent is root).

  • Tolerate non-String environment properties (#2348) — Loading environment/system properties whose values aren't String threw ClassCastException due to an unchecked map cast. Non-String values are now preserved as Any and only String keys are required.

  • Unique Ktor request-scope ids under concurrency (#2410) — Concurrent requests could collide on request-scope ids. Ids are now generated from a monotonic counter seeded once at startup. Thanks @lfavreli-betclic!

  • Actionable errors for SavedStateHandle / viewModelScope { } (#2044, #2417) — Resolving SavedStateHandle without the proper extras, or using viewModelScope { } without the viewModelScopeFactory() option, now produces a clear, actionable error message instead of an opaque failure.

Added
  • tvOS targets for koin-core-viewmodel (#2426) — koin-core-viewmodel now publishes tvosArm64, tvosX64, and tvosSimulatorArm64, unblocking ViewModel usage on tvOS.

  • Consumer R8/ProGuard rules + guide — Android and ViewModel artifacts now ship consumer R8/ProGuard rules in their AARs, and a new R8 / ProGuard guide documents keep rules for minified builds.

Improvements
  • O(1) secondary-type registration in bind() / binds()bind/binds now append secondary types in O(1) instead of reallocating the type list per binding, removing quadratic cost when a definition declares many bindings. No user-visible behavior change.
Documentation
  • Navigation 3 typed entryProvider (#2336) — Added guidance on using Koin with the typed entryProvider in the Navigation 3 reference.
Contributors

Thanks to the following contributors for this release:

4.2.1

Koin 4.2.1

Support for Compile Safety with Koin Compiler 1.0.0-RC1
Bug Fixes
  • Fix stacked-params lookup on linked scopes (#2387) — The 4.2.0 resolver rewrite (CoreResolverV2) walked linked scopes but dropped the per-parent stacked-parameters check that 4.1.x performed via recursion. This broke patterns where AndroidParametersHolder is stacked on the factory scope by KoinViewModelFactory and SavedStateHandle is then resolved from a child ViewModel scope. Linked-scope resolution now also checks stacked params on each parent scope.

  • Restore ABI compatibility for runOnKoinStarted (#2391) — The 4.2.0 release inadvertently broke binary compatibility for runOnKoinStarted on JVM. Fixed by restoring the original JVM class name via @JvmName/@JvmMultifileClass annotations.

  • Fix scope _closed concurrency issue (#2389) — The Scope._closed flag was not volatile, which could cause stale reads under concurrent access.

Improvements
  • Improved Scope resolution error messagesCoreResolverV2 now provides clearer error messages when scope resolution fails, making it easier to diagnose misconfigured scopes.

  • Added apiCheck to CI — Binary compatibility validation (kotlinx.binary-compatibility-validator) now runs on every PR to prevent future ABI breaks.

Documentation
  • parametersOf type-collision warning (#2328) — Added a caution note explaining that when a value passed via parametersOf has the same type as the requested definition, Koin returns the value directly and skips the factory block. Suggests using a wrapper type as a workaround.
Contributors

Thanks to the following contributors for this release:

4.2.1-RC1Pre-release

Koin 4.2.1-RC1

Koin 4.2.1-RC1
Bug Fixes
  • Fix ABI break on runOnKoinStarted (#2391) — The 4.2.0 refactor to move waitAllStartJobs to common code changed the JVM symbol for runOnKoinStarted from KoinWaitExtKt to KoinWaitExt_jvmKt, causing NoSuchMethodError at runtime for libraries compiled against 4.1.x. Fixed by adding @file:JvmName("KoinWaitExtKt") and @file:JvmMultifileClass to restore the original symbol.

  • Improved scope resolution error messages (#2379) — NoDefinitionFoundException now displays the full scope chain that was searched and indicates which scope qualifier is missing a definition, making scope resolution issues much easier to diagnose.

CI / Tooling
  • Added apiCheck to CI — The binary-compatibility-validator plugin was already configured but not running on PRs. apiCheck is now part of the CI build workflow, preventing accidental ABI breaks in future releases.
  • Updated .api dump files for all modules to reflect the current public API surface.
Still in progress for 4.2.1 final
  • PR #2389@Volatile on Scope._closed for concurrency fix
  • PR #2358 — Fix ClassCastException reading environment properties (#2348)
  • Documentation updates: #2339, #2336, #2328, #2218

4.2.0

Kotlin 2.3.20

New Features

  • Ktor 3.4 DI Bridge — Full integration with Ktor's new DI system (ktor-server-di), bridging Ktor ↔ Koin dependency injection both ways
  • Dagger Bridge (koin-dagger-bridge) — New module to help inject Koin components from Dagger side
  • AndroidX Navigation 3 support — Entry point provider with metadata parameter passing (animations, etc.), generic EntryProvider, and navigation scopes
  • Navigation Scope for Compose Nav 2 — Added scoped navigation support for Compose Navigation 2
  • Lazy Modules — Parallel loading at startup for improved performance, with benchmarks
  • strictOverride option — New definition option to override explicitly
  • koinActivityInject — Helper to retrieve dependencies against Activity scope
  • Koin Compiler Stubs — Added stubs for KoinApplication.modules() functions
  • KoinApplication.withConfiguration() — New configuration support

Performance & Stability

  • Core Resolver V2 — Fixed parameter stack propagation, injected params handling, and child scope/ViewModel scope resolution
  • Scope Resolution & Thread Safety — Performance optimization with safer ScopeFactory protecting all operations from parallel calls
  • ThreadLocal loading optimization — Avoid cost per Scope (#2306)
  • getAll no longer sorted by default — Instances come as declared; sort on purpose if needed
  • Params stack access optimization

Bug Fixes

  • Fix sharedKoinViewModel with type-safe navigation routes (#2293)
  • Fix qualified name usage in WASM (#2312)
  • Fix premature release of scope & context in Compose — don't drop in onForgotten (#2274)
  • Fix crashing declarations for LocalKoinScope & LocalKoinApplication
  • Fix Compose Koin Context Loader and Entry Points (#2327)
  • Fix CoreResolution with Child Scopes / ViewModelScope (#2325)
  • Fix Scope Archetypes Qualifier in plugin support functions
  • Fix qualifier conversion

Breaking Changes

  • minSdk raised to 23 for Android
  • module renamed to lazyModule in some contexts
  • BeanDef constructor change (API signature update)

Dependencies

  • Kotlin 2.3.20
  • Ktor 3.4
  • JetBrains Compose 1.10.2
  • AndroidX Lifecycle 2.10.0
  • AndroidX Navigation 2.9.7 / Nav3 1.0.1
4.2.0-RC2

Koin 4.2.0-RC2

Second Release Candidate for Koin 4.2.0, upgrading to Kotlin 2.3.20-RC2 and updating dependencies.

What's Changed
Kotlin 2.3.20-RC2 Upgrade
  • Upgraded Kotlin from 2.3.20-Beta1 to 2.3.20-RC2 - #2377 by @arnaudgiuliani
Koin Compiler Plugin: New KoinApplication.modules() Stubs
  • Added compiler plugin stubs for KoinApplication.modules<T>() (reified single module) and KoinApplication.modules(vararg KClass<*>) (multiple modules) — enabling type-safe module loading via the Koin Annotations compiler plugin
Koin Compiler Plugin 0.4.0 Support
  • Added compiler plugin stubs for KoinApplication.modules<T>() (reified single module) and KoinApplication.modules(vararg KClass<*>) (multiple modules) — enabling type-safe module loading via the Koin Compiler Plugin
Dependency Updates
  • Kotlin: 2.3.20-Beta1 → 2.3.20-RC2
  • Compose Multiplatform: 1.10.0 → 1.10.2
  • AndroidX Activity: 1.12.2 → 1.12.4
  • AndroidX WorkManager: 2.11.0 → 2.11.1
  • AndroidX Navigation: 2.9.6 → 2.9.7
  • AndroidX Navigation3: 1.0.0 → 1.0.1
  • JetBrains Navigation: 2.9.1 → 2.9.2
  • Robolectric: 4.16 → 4.16.1
  • Benchmark: 0.4.15 → 0.4.16
Full Changelog

https://github.com/InsertKoinIO/koin/compare/4.2.0-RC1...4.2.0-RC2

4.2.0-RC1

Koin 4.2.0-RC1

This Release Candidate consolidates all features, improvements, and bug fixes from the alpha and beta series. The focus has been on Compose integration stability, scope resolution improvements, Ktor 3.4 DI Bridge, and compiler plugin support.

Highlights
Ktor 3.4 DI Bridge Integration
Navigation 3 Support
Compose Improvements
ViewModelScope Updates
  • ⚠️ Breaking ⚠️: ViewModel declarations requiring scope injection must now be inside viewModelScope { } block
  • Improved CoreResolverV2 for proper child scope/ViewModel scope resolution - https://github.com/InsertKoinIO/koin/pull/2340 by @arnaudgiuliani
Koin Compiler Plugin Support API
New internal APIs for Koin Annotations compiler plugin:
Core Improvements
Bug Fixes
Dependencies
  • Kotlin 2.3.20-Beta1
  • Ktor 3.4.0
  • Coroutines 1.10.2
  • Compose Multiplatform 1.10.0
  • AndroidX Lifecycle 2.10.0 / JetBrains Lifecycle 2.9.6
  • AndroidX Navigation 2.9.6 / JetBrains Navigation 2.9.1
  • AndroidX Navigation3 1.0.0
New Modules
  • koin-compose-navigation3 - Navigation 3 integration
  • koin-annotations - Core annotations module
  • koin-dagger-bridge - Dagger to Koin bridge
Removed
Breaking ⚠️
  • ViewModel Scope Constructor Injection (still experimental) - ViewModel declarations requiring scope injection must now be declared inside viewModelScope { } block
Contributors

Thanks to all contributors: @arnaudgiuliani, @nhajratw, @egorikftp, @GrzegorzBobryk, @jvanderwee, @xephosbot, @nazaburo, @luozejiaqun

Full Changelog: https://github.com/InsertKoinIO/koin/compare/4.1.1...4.2.0-RC1

4.2.0-beta4

Pre-release

Koin 4.2.0-beta4

New Features

Ktor 3.4 DI Bridge Integration (https://github.com/InsertKoinIO/koin/pull/2294)

Koin Plugin Support Improvements

Bug Fixes

Dependencies

Note: This release requires the Ktor EAP repository. Add the following to your settings.gradle.kts:
maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap")

Full Changelog: https://github.com/InsertKoinIO/koin/compare/4.2.0-beta3...4.2.0-beta4

4.2.0-beta3

Pre-release

4.2.0-beta3

⚠️ ViewModelScope Declaration Requirement Updated

Experimental Feature: The automatic scope creation for ViewModel constructor injection now requires ViewModel declarations to be part of the viewModelScope section. If declared outside, injection will look in the root scope instead of the ViewModel scope, causing resolution failures.

  // Injection against root scope
  viewModel { MyViewModel(get()) }

  // Injection against viewModel scope
  viewModelScope {
      viewModel { MyViewModel(get()) }
  }
Koin Compiler Plugin Support API

New Plugin Support API for Koin Annotations compiler plugin integration:

  • ModuleExt - Module extensions for plugin-generated code
  • CreateDSL - DSL for plugin code generation
  • BaseDSLExt - Base DSL extensions
  • ApplicationDSLExt - Application-level DSL extensions
  • ViewModelDSLExt / ViewModelModuleExt - ViewModel support for plugin
  • WorkerDSLExt / WorkerModuleExt - Android Worker support for plugin
Bug Fixes
Features & Improvements
Libraries & Dependencies
  • Kotlin 2.3.20-Beta1
  • Coroutines 1.10.2
  • Compose Multiplatform 1.10.0
  • AndroidX Lifecycle 2.10.0 / JetBrains Lifecycle 2.9.6
  • AndroidX Navigation 2.9.6 / JetBrains Navigation 2.9.1
  • AndroidX Navigation3 1.0.0
  • Ktor 3.3.3
Other
  • Clean up koin-fu + koin-annotations beta3 plugin by @arnaudgiuliani (932c1540)
  • Moved koin-fu lib to Koin beta3 plugin by @arnaudgiuliani (a9daf9bf)
  • KDoc update for EntryProvider by @arnaudgiuliani (0539c48b)
  • Delete CHANGELOG.md by @jvanderwee in https://github.com/InsertKoinIO/koin/pull/2308
New Contributors

Full Changelog: https://github.com/InsertKoinIO/koin/compare/4.2.0-beta2...4.2.0-beta3

4.2.0-beta2

Pre-release
What's Changed

Full Changelog: https://github.com/InsertKoinIO/koin/compare/4.2.0-alpha3...4.2.0-beta2

Discussion