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

    arnaud.giuliani

    10/07/2025, 1:23 PM
    Koin Annotations 2.2 is released with big new features 🎉 • JSR 330 Compat • Smart Configurations • Scope Archetypes Take a look 👇 https://medium.com/koin-developers/koin-annotations-2-2-jsr-330-compatibility-smart-configurations-and-scope-archetypes-5b2f4c8536c1
    nice spin 3
    🆒 2
    🎉 10
    👀 1
  • i

    Irsath Kareem

    10/10/2025, 3:04 AM
    Whether KSP Version (2.2.20-2.0.3) is supported by koin annotations 2.2 I see in Koin Annotations Documentation, that Latest KSP Support is 2.1.21-2.0.2 Whether I need KSP to be downgraded??????
    a
    • 2
    • 1
  • i

    Irsath Kareem

    10/10/2025, 4:39 AM
    One more: 1. Constructor provider Possible when using Koin Annotations a.
    singleOf(::DatabaseFactory)
    a
    • 2
    • 3
  • b

    bartek.t

    10/10/2025, 1:00 PM
    Do I understand RememberObserver correctly? Once I create a custom scope related to a navigation route and it’s placed in the back stack, will RememberObserver trigger the disposal of any custom scope created with the KoinScope() function?
    a
    • 2
    • 3
  • h

    Horatio Thomas

    10/12/2025, 5:00 AM
    Anyone know how you would get the ktor environment context in a ktor appModule?
    a
    • 2
    • 2
  • f

    Farhazul Mullick

    10/15/2025, 9:56 AM
    Is Annotation based koin in koin 4.1 Compile time library like Hilt?
    a
    • 2
    • 4
  • m

    Mark

    10/15/2025, 1:04 PM
    I’m migrating as much androidMain code to commonMain as possible. I’m wondering about viewmodels associated with the
    MainActivity
    which I currently access using:
    Copy code
    inline fun <reified T : ViewModel> koinActivityViewModel(
        qualifier: Qualifier? = null,
        key: String? = null,
        scope: Scope = currentKoinScope(),
        noinline parameters: ParametersDefinition? = null,
    ): T = koinViewModel<T>(
        qualifier = qualifier,
        viewModelStoreOwner = LocalActivity.current as ComponentActivity,
        key = key,
        scope = scope,
        parameters = parameters,
    )
    Claude is recommending I just use
    single { }
    for such a view model. Thoughts?
    s
    a
    • 3
    • 18
  • 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 5
    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