InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
9.1k stars 720 forks source link

Koin Annotations not working for expect/actual classes #2050

Closed cj3g10 closed 1 week ago

cj3g10 commented 2 weeks ago

Describe the bug I'm unsure how to use Koin Annotations with expect/actual classes as it seems to not work no matter how I set it up. The documentation shows that you should annotation to the actual class. On the other hand, the Hello Koin KMP sample app does it different and adds the annotaiton to the expect class. However, no matter whether I add the annotation to the expect class, to the actual class, or to both expect and actual class, Koin will throw a NoDefinitionFoundException. The ksp generated Module file will not contain the annotated class.

Note that if I define the actual class via code, it works fine, so this isn't an issue that is blocking my development.

To Reproduce Steps to reproduce the behavior:

  1. Setup koin.
  2. Create an expect/actual class.
  3. Add @Single or @Factory annotation to the actual class.
  4. Run app and attempt to inject said class.

Expected behavior The class will be injected properly and app will run smoothly.

Actual behavior The app will crash and throw NoDefinitionFoundException.

Koin module and version: koin-annotations:2.0.0-Beta1

arnaudgiuliani commented 1 week ago

can you reopen in https://github.com/InsertKoinIO/koin-annotations/issues ?