Open danielesegato opened 3 months ago
Duplicate of #95. Since you provide the external dependency in the Koin DSL, which is runtime, the compiler check cannot verify it at build time, hence the error.
I made the example with a "config" class but how am I going to access the application android context, for instance, from a module with kotlin-annotation if the only way to inject that is from the application?
I know I can expose a method to create the module of my library that inject the context, however in a modularized app it is way more convenient if that's provided by the app and modules that needs it can access it in the android side of the code.
you can use context
Android parameter as injected in your class. Koin annotations won't need to declare anything.
Describe the bug It is OK for library modules to have some Missing Definition, this shouldn't be checked by KOIN_CONFIG_CHECK, or at least it shouldn't be the default behavior.
To Reproduce
import org.koin.core.annotation.ComponentScan import org.koin.core.annotation.Factory import org.koin.core.annotation.Module
data class Config(val dummy: String)
@Factory class ExternallyConfigurableComponent( val config: Config ) { fun useConfig() { println(config.dummy) } }
@Module @ComponentScan("com.example") class MyModule
Koin project used and used version:
Additional informations If I have an Android Application depending on this it should be possible to define another module injecting
Config
. And this works perfectly fine if I disable the check.You can try yourself by creating an android application depending on the library and injecting in the Application onCreate:
and than injecting
ExternallyConfigurableComponent
and callinguseConfig
it will print
foo
if you disable the check, and it will not compile if you enable the check.Dagger / Hilt also works this way: you can inject from outside a module as long as it is not an application module.