InsertKoinIO / koin

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

[ksp] Unable to process:org.koin.compiler.BuilderProcessor #1742

Closed congvc-dev closed 4 months ago

congvc-dev commented 11 months ago

Describe the bug Hi everyone, I currently have a problem in my android project. All the necessary information is located in the Reproduce section. I hope you can diagnose the problem and fix the issue.

To Reproduce Steps to reproduce the behavior:

  1. Create an android :app application module
  2. Create 2 module :api, :impl, both are android library modules and uses these Koin components: koin-android, koin-core, koin-ksp-compiler and koin-annotations
  3. :impl uses :api.
  4. :app uses both of them
  5. In :api, create interface B. In :impl, create @Single class A : B
  6. In :impl, create @Module @ComponentScan class FeatureModule to collect all the components
  7. In :app create a @Module(includes = [FeatureModule::class]) class ApplicationModule
  8. Hit build button
  9. Observe Build Output tool windows there is a warning [ksp] Unable to process:org.koin.compiler.BuilderProcessor: A in task :impl:kspDebugKotlin
  10. There is an error in task :app:compileDebugKotlin
    e: file:///MyProject/app/build/generated/ksp/debug/kotlin/org/koin/ksp/generated/ApplicationModuleGencom$di.kt:14:222 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
    public val FeatureModule.module: Module defined in org.koin.ksp.generated

Expected behavior

Koin module and version (in my libs.versions.toml file): ksp = "1.9.21-1.0.16" koinAnnotation = "1.3.0" koinBom = "3.5.1" koinCompiler = "1.3.0" androidGradlePlugin = "8.2.0" gradleWraper: v8.2

Snippet or Sample project to help reproduce

congvc-dev commented 11 months ago

My workaround is manually create binding in FeatureModule:

@Module
@ComponentScan(..)
public class FeatureModule {
    @Single
    internal provideB(): B = A()
}
arnaudgiuliani commented 9 months ago

did you put the package in @ComponentScan(..)?

also it's in wrong repo. But that's ok if we solved it.

congvc-dev commented 9 months ago

@arnaudgiuliani I did. Would a sample repo help you reproduce the issue?

arnaudgiuliani commented 9 months ago

yes please 🙏

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.