Hey folks, I'm encountering a rather strange issu...
# koin
s
Hey folks, I'm encountering a rather strange issue. I'm using koin annotations. I have a some gradle modules set up like this:
Copy code
module A:
 interface A

module B:
 interface B

 @Single(binds = [B])
 internal class BImpl : B
 
 @Module 
 @ComponentScan
 class KoinModuleB

module C:
 interface C

 @Factory(binds = [C])
 internal interface CImpl(val b: B, val a: A) : C

 @Module 
 @ComponentScan
 class KoinModuleC

app module:
 class AImpl : A

 @Module(includes = [KoinModuleB, KoinModuleC]
 AppModule {
  fun provideA(impl: A): A
 }
The generated code properly registered the dependencies. Unfortunately however, compilation fails in module C with a
Copy code
Missing Definition type '<package a>.A' for '<package c>.C'. Fix your configuration to define type 'A'.
I think somehow, it tries to fulfill the dependencies in Gradle module C while I have defined the implementation in the app module. Is there a way to go around this?
1
when i moved
class AImpl
to gradle module A, and created a koin module there, everything worked fine 🤔
is it a technical limitation that makes it impossible to provide concrete implementations in a module higher than where it is used?
👌 1
p
I marked it as self-found 🙂 , but thanks for the effort you put into reproducing it. Feel free to add this information to the issue. More information is better than less.
s
Yeahh! I can add it. I honestly spent so much time. I thought I did something wrong. Anyway, I looked in the compiler code and I kind of know why it's happening. If my understanding is correct, koin generates some empty files with the package name and file name for each component that was fulfilled by the generated module, and if that file does not exist, koin assumed that a definition for it was not provided. That file is generated in the other gradle module, but koin validator doesn't know this because it only looks locally.
👍 1