Hi, I have an issue with type qualifier annotation...
# koin
d
Hi, I have an issue with type qualifier annotation (
@Qualifier
) when using R8, because code generation is done before obfuscation… is there any work around this except keeping the type un-obfuscated? Also would it be possible to create module using DSL (
module{ }
) and then include that module into module declared via annotation (
@Module
)? I guess easy work around then would be to create module via DSL which contains definitions with qualifiers and include it back to module hierarchy defined with annotations
I figured out a way to achieve desired behaviour but I am not sure how resilient the solution is for the future Koin changes:
Copy code
@Module
class MyModule

// Without @Module
class MyModuleExtension {
    val module : org.koin.core.module.Module get() = module {
        includes(MyModule().module)

        // my definitions with qualifier<T>()
    }
}

@Module(includes = [
    //MyModule::class,
    MyModuleExtension::class,
])
class AppModule
@arnaud.giuliani it would be nice to hear your opinion on this: is this “hack” acceptable or we maybe need a way to annotate function that provides dsl module definition to a module defined with annotations, similar way we can use
@Single
etc
a
You can tag @Provided the elements that are declared out of Annotations modules
Hi, I have an issue with type qualifier annotation (
@Qualifier
) when using R8, because code generation is done before obfuscation… is there any work around this except keeping the type un-obfuscated?
ok, interesting. Not reported until now
need to see why this. Can you ask the question also on #C013BA8EQSE ?
d
I can ask, but let’s first see if this is a ksp problem, I think it’s probably code generation issue because generated code for
@Qualifier
is
org.koin.core.qualifier.StringQualifier("com.example.MyClass")
instead of
qualifier<com.example.MyClass>()
and then since ksp runs before R8 we end up with unobfuscated string qualifier in generated code while when using injection at runtime we would probably do
qualifier<MyClass>()
where
MyClass
is now a obfuscated and generating a different qualifier (
StringQualifier("a.b.C")
)
@Provided
is used to ignore compile time safety for a type, right? What I asked for is how to include dsl declared module into annotation declared module. As far as I know we can include dsl module into dsl module, annotated module into annotated module, and annotated module into dsl module but I am not sure to include dsl module into annotated module, the example from above is a hack since it imitates koin code generation (generated property
val module : org.koin.core.module.Module get()
) but if you change how the code generation work it will break probably