kotlin-inject
kotlin-inject copied to clipboard
KSP throws an exception when using an interface from another module to declare a property in a component
Hi! I want to use kotlin-inject in my multi modules multi platform project. But when I use interface from another module for declare a property in my component I get an exception:
e: Error occurred in KSP, check log for detail [ksp] Unresolved reference: MyInterface
and
[ksp] Unable to process:me.tatarka.inject.compiler.ksp.InjectProcessor: ModuleComponent
Same here for third-party interfaces/classes. I can't get a @Provides annotation to work for this case. I'm using a workaround with delegates, but this is currently a show stopper for me.
(I can use types of other modules in my project though)
Ok so the solution for me was to include the dependencies in the module that has the component. My Situation: Android App, several modules, @Provides declared in one interface per module that are implemented by an AppComponent in the app module (similar to tivi app https://github.com/chrisbanes/tivi/blob/76c9ffea05ba86810a344e6ca5f936db2c67fce7/shared/prod/src/androidMain/kotlin/app/tivi/inject/AndroidApplicationComponent.kt#L25)
The app module (with the kotlin-inject component in it) needs access to all declared @Provides return types. So i need to either change third-party dependencies to "api" or add them to the app's implementation configuration. This is not the case with dagger, so it confused me.
Ah yes, the codegen has less indirection than dagger which causes this as a side-effect. Can look into seeing if there's more cases where you could 'hide' the types provided though there are trade-offs there.
Is there an update on this? I would really like to use kotlin-inject, but I'm having trouble in my multi-module project as well for the same reason.