Open sudansh opened 8 months ago
why this doesn't work. Can you provide mode details?
Created a sample project with bug https://github.com/sudansh/koinBug/
Error while building
e: [ksp] --> Missing Definition type 'android.content.Context' for 'app.sudansh.domain.PreferencesHelper'. Fix your configuration to define type 'Context'. e: Error occurred in KSP, check log for detail
I saw this issue https://github.com/InsertKoinIO/koin-annotations/issues/49 and I believe this is not possible yet now to pass context
with annotations.
it's possible with androidContext(...)
line in your startKoin
section. But verification seems to look for it
Have already put androidContext()
in startKoin
but context isn't found in multi module app. It works if PreferenceHelper
is in same module as startKoin
I don't see why your other module couldn't find your android Context if it's been injected since your startKoin section?! 🤔 Can you gives more details about how your are launching your other modules?
koin-core: 3.5.0 koin-annotations: 1.3.0
If I turn on Compile Safety, the compilation will get this error, not set, the compilation is normal.
e: [ksp] --> Missing Definition type
https://github.com/InsertKoinIO/hello-kmp/blob/annotations/shared/build.gradle.kts#L67
The recommended configuration was not used because an error would be reported.
dependencies {
"kspCommonMainMetadata"(libs.findLibrary("koin-compiler").get())
"kspAndroid"(libs.findLibrary("koin-compiler").get())
"kspDesktop"(libs.findLibrary("koin-compiler").get())
}
yes, definitely need to update this project with the new compiler option. Also linked to this PR: https://github.com/InsertKoinIO/koin-annotations/pull/101
same issue when using context for create a database in the data module, context doesn't work :(
same issue when using context for create a database in the data module, context doesn't work :(
is it a KMP app? are you injecting on Android part?
same issue when using context for create a database in the data module, context doesn't work :(
is it a KMP app? are you injecting on Android part?
I have been using the Koin annotation in my Android project, but unfortunately, it doesn't work in multi-module setups. I then switched to using Koin without annotations.
I like the annotation feature, it just didn't work for me in this case (multi module). In my open-source project with a multi-module app, I have successfully used Koin (without annotations), which has worked well for me.
can you check with the latest 1.3.1? Some of you here were having config validation problem
Absolutely, I will keep you informed.
Describe the bug Injecting Context/Application in single module app works but doesn't work in multi module app
To Reproduce Steps to reproduce the behavior:
startKoin{ androidContext(applicationContext) }
This works in app module
@Single fun prefsApp(context: Context) = Preferences(context)
@Single fun prefsFeature(context: Context) = Preferences(context)
Expected behavior prefsFeature should be able to inject
context
Koin project used and used version (please complete the following information):
koin-annotations-bom version 1.3.0