https://kotlinlang.org logo
Join Slack
Powered by
# koin
  • s

    Shahid Iqbal4213

    10/18/2025, 5:31 PM
    Hey team i'm facing strange issue when using name qualifier can someone tell whats wrong here and how can i set? Koin Version 4.1.1 Issue: _Type is not declared in Koin modules: retrofit2.Retrofit (auth_retrofit)_
    Copy code
    internal val authApiModule = module {
        single<Retrofit>(named(AUTH_RETROFIT_QUALIFIER)) {
            Retrofit.Builder()
                .baseUrl("<https://api.example.com/>") // Base URL must be set here
                .addConverterFactory(GsonConverterFactory.create())
                .client(get<OkHttpClient>(qualifier = named(OKHTTP_CLIENT_QUALIFIER)))
                .build()
        }
    
        factory<AuthApi> {
            provideApi(
                get<Retrofit>(qualifier = named(AUTH_RETROFIT_QUALIFIER)),
                AuthApi::class.java
            )
        }
    }
    and AuthApi module is added to main module
    Copy code
    val authFeatureModule = module {
    
        includes(authNavModule, authApiModule, authMainModule)
    }
    a
    • 2
    • 1
  • i

    Irsath Kareem

    10/19/2025, 8:20 AM
    When using Koin Annotations 2.2.x This is the basic multi module setup, :app --> featurepresentation --> featuredomain <--impl-- featuredata
    @KoinApplication
    is available in
    :app
    module, (it looks for @Configuration in its direct child modules) Let's assume, I want to write
    @Configuration("test")
    in
    :feature:data
    module. (which needs to load only in tests.) This configuration is automatically loaded by
    :app
    module's
    @KoinApplication(config... = ["test"])
    ????? I think, Currently, It is not. Can you help me?, Or any other workaround???
    a
    • 2
    • 4
  • o

    Otávio Gabriel (Tavieto)

    10/20/2025, 7:08 PM
    Hello everyone! I'm needing some help related to tests with Koin. What's the main difference between the old and now deprecated
    checkModules
    to the new
    verify
    ? Because I'm seeing some scenarios where verify should fail, but it's not failing. Maybe I'm getting something wrong. If not, I would like to contribute to the project.
    a
    • 2
    • 8
  • a

    arnaud.giuliani

    10/22/2025, 7:28 AM
    I'm starting to align the Koin ecosystem on Kotlin 2.2.x Here is Koin Annotations 2.3 track, using latest KSP & Kotlin 2.2.20 - https://github.com/InsertKoinIO/koin-annotations/releases/tag/2.3.0
    🎉 5
  • o

    Otávio Gabriel (Tavieto)

    10/22/2025, 11:34 PM
    I have answered an issue on github and wasn't really an issue, just a misunderstanding. In that case, should I report to someone to close the issue?
    p
    • 2
    • 2
  • f

    FlowFan

    10/23/2025, 4:01 AM
    When upgrading koin-annotations from 2.1.0 to 2.3.0, how should Koin be initialized? Here is my previous multiplatform entry code, which now fails to compile with "Unresolved reference 'defaultModule'". Also, I would like to ask if there is a new way to initialize Koin for multiplatform in the new version, such as using annotations?
    Copy code
    @Composable
    @Preview
    fun App(
        modifier: Modifier = Modifier,
        darkTheme: Boolean = isSystemInDarkTheme(),
        navController: NavHostController = rememberNavController()
    ) {
        KoinApplication(
            application = {
                modules(AppModule.module)
                defaultModule()
            }
        ) {
            MainScreen(navController = navController)
        }
    }
  • c

    Chirag Redij

    10/25/2025, 12:50 PM
    Out of no where I am getting this issue
    Copy code
    Package 'core.data' was compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler.
    Here are my Kotlin versions
    Copy code
    kotlin = "2.2.20"
    ksp = "2.2.20-2.0.4"
    Koin versions
    Copy code
    koin-core = "4.1.1"
    koin-annotation = "2.3.0"
    a
    • 2
    • 1
  • d

    Denys

    10/27/2025, 2:32 PM
    Could you please tell me how to use Koin in an isolated context in my SDK?
    a
    • 2
    • 2
  • a

    arnaud.giuliani

    11/05/2025, 4:46 PM
    Hello all 👋 we have some KSP2 breaking with Koin Annotations for KMP apps. I'm looking for help on it: https://github.com/InsertKoinIO/koin-annotations/issues/317
    👍 2
  • a

    arnaud.giuliani

    11/05/2025, 4:47 PM
    for KMP apps users, you can continue with KSP 2.1.20. Android users are not impacted
  • b

    Bart

    11/05/2025, 7:51 PM
    Is it possible to use
    @KoinApplication
    in other source set than
    commonMain
    (e.g.
    commonTest
    or custom)? I have custom source set for instrumented tests (it includes
    commonMain
    like
    commonTest
    does), and
    @KoinApplication
    when used in this source set not generated the code properly, needed to put it in
    commonMain
    . Would be useful/cleaner is such test koin application could be created in test source set.
  • a

    Anuta Vlad Sv

    11/06/2025, 9:59 AM
    Hi! I'm using KoinStartup in a KMP project, but my StartupBenchmarks show it actually made cold start slightly slower, not faster. I'm using io.insert-koinkoin androidx startup4.1.1 My theory: Deep, tangled dependency chains are the root cause. Even though KoinStartup runs earlier in the process, all 15+ modules are still created synchronously on the main thread because they depend on each other — no real lazy loading happens. What’s the right strategy to break this cycle and actually improve startup time?
  • m

    Michal Klimczak

    11/06/2025, 10:24 AM
    Any ideas why this stops working when migrating from 1.4.0 to 2? Tried a few different 2+ versions, currently 4.1.1 + 2.2.0. KMP project
  • p

    Pedro Francisco de Sousa Neto

    11/06/2025, 12:17 PM
    Hi! I'm trying to migrate from AndroidX Navigation in a KMP project to Koin Navigation (using modules etc, version 4.2.0-alpha1). I've implemented in common dependencies:
    Copy code
    // build.gradle.kts
    implementation(libs.koin.core)
    implementation(libs.koin.core.coroutines)
    implementation(libs.koin.compose)
    implementation(libs.koin.compose.viewmodel)
    implementation(libs.koin.compose.viewmodel.navigation)
    implementation(libs.koin.compose.navigation)
    
    // libs.versions.toml
    koin = "4.2.0-alpha1"
    koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin" }
    koin-compose-viewmodel = { module = "io.insert-koin:koin-compose-viewmodel", version.ref = "koin" }
    koin-compose-viewmodel-navigation = { module = "io.insert-koin:koin-compose-viewmodel-navigation", version.ref = "koin" }
    koin-compose-navigation = { module = "io.insert-koin:koin-compose-navigation3", version.ref = "koin" }
    koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
    koin-core-coroutines = { module = "io.insert-koin:koin-core-coroutines", version.ref = "koin" }
    koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
    I couldn´t find the import for
    NavigationHost
    in a
    @Composable
    function. What am I missing?
    🔥 1
    a
    t
    • 3
    • 7
  • a

    Albertas

    11/10/2025, 4:08 PM
    Hi, I'm checking out
    4.2.0-alpha1
    and it seems to always throw an exception when being initialized with KoinMultiplatformApplication:
    Copy code
    java.lang.IllegalStateException:  should not be used in favor of LocalKoinScopeContext
    	at org.koin.compose.KoinApplicationKt.<clinit>(KoinApplication.kt:48)
    ...shouldn't the error be within compositionLocalOf?
    👀 1
    a
    • 2
    • 1
  • l

    Laurent Thiebaud

    11/12/2025, 9:43 AM
    Is there a recommended way of injecting dependencies for a backend application, between
    by inject()
    or annotations?
    a
    • 2
    • 1
  • j

    Jason Toms

    11/13/2025, 12:15 PM
    Trying to use Koin Annotations with the compile time check, but having some issues with interfaces. This github issue seems to describe my problem, but there is no resolution...what is the best workaround for this today? I have an interface in a low level module that everything depends on, but the implementation is in a higher module, and added to the dependency graph there. But I need to use this dependency in the middle, in modules that cannot depend on the higher module. Without the compile time check this works fine, and I am pretty sure this is a common pattern in dependency injection systems?
  • j

    Jason Toms

    11/14/2025, 11:44 AM
    Is there a clever way to get
    @Configuration
    to work in an Android project, or will I need to manually add every module? I can't find a way to combine using
    @KoinApplication
    and also providing android context and work manager
    ✅ 1
    a
    • 2
    • 2
  • s

    Soumen pal

    11/17/2025, 12:09 PM
    Hey Right Now KClass I mean koin cant create instances of some Class that inherits NSObject or any objC classes??
  • a

    arnaud.giuliani

    11/17/2025, 4:52 PM
    Hello all 👋 here is a complete migration guide using Now In Android as a real-world example. It uses Koin Annotations 2.3 Key points 👉 • JSR-330 compatibility - step-by-step migration • @KoinApplication + @Configuration scale module discovery effortlessly • Smoother scope management with Scope Archetypes • Compile-time safety 📖 The full article: https://blog.insert-koin.io/migrating-now-in-android-to-koin-annotations-2-3-67d252dbb97d
    koinscroll 7
    s
    k
    • 3
    • 7
  • j

    Joost Klitsie

    11/19/2025, 1:39 PM
    Dear people! I am trying to introduce Koin Annotations in a project with Dagger2 (no hilt). I want to build from the bottom up at first (lots of legacy here, can't 1-shot it) to transform the project to KMP. I am trying to start the koin application. However, it is finding all my good old javax.inject.Inject @Inject constructors that we use with Dagger, and I guess the @Modules and whatnot, and it is not playing nicely together 😄 . Is it possibly to make the Koin Annotations KSP stuff ignore these, at least for now? It would be good if it only finds the Koin annotations and not the java inject ones.
    ✅ 1
    a
    • 2
    • 5
  • a

    Alexis

    11/19/2025, 4:11 PM
    Hello everyone, I'm working on a KMP App and chose to export the Kotlin Shared code to iOS by exporting an xcframework (using the assembleXCFramework gradle task), I then import the framework in my code XCode project. The thing is that I get this error:
    Copy code
    Can't show file for stack frame : <DBGLLDBStackFrame: 0x9e7761cc0> - stackNumber:1 - name:kfun:org.koin.core.context.MutableGlobalContext#<init>(){} [inlined]. The file path does not exist on the file system: /Users/runner/work/koin/koin/projects/core/koin-core/src/nativeMain/kotlin/org/koin/core/context/GlobalContext.ktMessage from debugger: killed
    when initializing Koin. Kotlin side:
    Copy code
    class DependencyProvider {
        fun initKoin() {
            RendrLog.logInfo(this::class.simpleName, "Initializing Koin...")
            val instance = startKoin {
                modules(Modules.features)
            }
            koin = instance.koin
        }
    
        companion object {
            lateinit var koin: Koin
        }
    }
    XCode side:
    Copy code
    public struct DIHelper {
        
        public static func initKoint() {
            let koinDependencyHelper = DependencyProvider()
            koinDependencyHelper.doInitKoin()
        }
        
    }
    Everything was working previously when importing my shared kotlin code my Scheme > Build > Pre-action > script running "embedAndSignAppleFrameworkForXcode" I could't find any link about this error, so I wanted to know if anyone already encountered this error, or if you have an idea? 🙂 Have a nice day
    a
    • 2
    • 1
  • j

    Jason Toms

    11/21/2025, 11:17 AM
    How can we customize navigation animations with nav3 and koin? The
    navigation
    definition seems to abstract away the
    entry
    , where animations are defined.
    a
    • 2
    • 5
  • m

    Michal Klimczak

    11/25/2025, 4:54 PM
    I have really hard time trying to migrate koin annotations from 1.x to 2.x. Multiplatform app, but everything works fine except for the android module. In 1.x I had my AndroidModule which scanned through the android gradle module and found all 46 viewmodels just fine. Now simply changing version of koin-annotations to 2.x makes this AndroidModule to be unresolved (it stops being generated). I tried using the deprecated defaultModule (with KSP flag) and it does generate but somehow it only generates definitions for 22 of my viewmodels.
    Copy code
    kotlin = "2.1.10"
    ksp = "2.1.10-1.0.31" //tried ksp2 as well
    koin = "4.1.1"
    koinAnnotations = "2.2.0"
    More details in 🧵 as not to spam here too much
    s
    a
    • 3
    • 14
  • r

    RJ Garcia

    11/25/2025, 5:47 PM
    Hi, is there any best practice for how to define koin modules that might require configuration to change the behavior or actual instances of the registered services? An example I have is a module that registers SSLContext and related services. In prod, I might have a service that will actually try and refresh the ssl context on a schedule, but in dev environment i might not need that. Or I might want to configure to load cert files from one location in deployment context, but look at a separate set of folders for the cert files in a different deployment context. My current approach is to have "*ModuleConfig" class that i register a default version of in the module, and then callers can then redefine their own *ModuleConfig instance if they need to override things in different environments. This isn't super ergonomic with koin though, and I don't see any docs or discussions around this. So I wonder if i'm thinking about this incorrectly
  • h

    holgerbrandl

    11/27/2025, 5:50 PM
    Not sure if/how old thread are noticeable in here, so if anyone has an idea about the semantics of
    createdAtStart
    as asked in the very old thread https://kotlinlang.slack.com/archives/C67HDJZ2N/p1764251929732999?thread_ts=1671535899.858929&amp;cid=C67HDJZ2N I'd be very happy and highly appreciate your support.
    • 1
    • 1
  • l

    Lukáš Kúšik

    11/28/2025, 4:44 PM
    With Navigation 2 we had some ViewModels shared between screens in a nested graph through their parent
    NavBackStackEntry
    as
    viewModelStoreOwner
    . Does anyone have a similar setup on how to achieve this with Navigation 3?
  • s

    shikhar

    12/02/2025, 6:34 PM
    Seems like this bug could create issues when defining DI modules and using get() in Koin on JS targets with kotlin 2.2.21: https://youtrack.jetbrains.com/issue/KT-80991
  • o

    Oleksandr Balan

    12/02/2025, 9:00 PM
    Hi 👋 Does scoping a ViewModel (injected via Koin) to a Navigation3 back stack entry work in Compose Multiplatform? Basically I am running into the issue described here: https://github.com/InsertKoinIO/koin/issues/2235, but I am already using
    org.koin.compose.viewmodel.koinViewModel()
    , but the ViewModel is not being cleared when the Nav3 entry is popped. Is this expected for CMP / Nav3, or am I missing something in the setup? Thx for any hints.
    Copy code
    Koin : 4.2.0-alpha3
    CMP  : 1.10.0-rc01
    Nav3 : 1.0.0-alpha06
    z
    • 2
    • 4
  • r

    Roger Kreienbühl

    12/04/2025, 1:33 PM
    Hi everyone I tried updating koin-annotations, but every version after 2.1.0 leads to errors
    [ksp] --> Unreachable definition
    for every definition with annotations. I initialized the modules by default modules, but updated to the
    @KoinApplication
    way when trying to update to koin-annotations 2.3.1, but nothing worked. With koin-annotations 2.1.0 everything works as it should. Am I missing something when updating? Kotlin version: 2.2.21 KSP version: 2.3.2 Koin version: 4.1.1
    g
    • 2
    • 2