[Koin annotations]
Title: KSP Validation False Positive for Cross-Module Interface Bindings in KMP Project
Environment
- Koin Version: 4.0.2
- Koin Annotations: 2.0.0
- Koin KSP Compiler: 2.0.0
- KSP Version: 2.1.10-1.0.30
- Kotlin Version: 2.1.10
- Gradle Version: 8.12
- Platform: Android/iOS (KMP)
Problem Description
When using Koin with KSP in a KMP multi-module project, the KSP validation incorrectly reports a missing dependency during compilation (Missing Definition for property 'AuthRepository'), even though:
- All bindings are correctly annotated with
@Single(binds = [...]. - Modules are properly included in the root Koin module.
- Dependencies between modules are correctly configured.
The project works at runtime when validation is disabled via KOIN_CONFIG_CHECK = false, proving the bindings are valid.
Steps to Reproduce
-
Project Structure:
-
domainmodule: Declares interfaces (AuthRepository,AuthInteractor). -
datamodule: ImplementsAuthRepositoryImplwith@Single(binds = [AuthRepository::class]). -
dimodule: Aggregates all modules via@Module(includes = [...]).
-
-
Configuration:
- All modules have KSP plugin and dependencies:
ksp("io.insert-koin:koin-ksp-compiler:2.0.0") -
datamodule depends ondomain. - Root
dimodule includes all submodules.
- All modules have KSP plugin and dependencies:
-
Error:
- Compilation fails with:
[ksp] --> Missing Definition for property 'authRepository : com.example.domain.AuthRepository' in 'com.example.domain.AuthInteractorImpl'
- Compilation fails with:
Expected Behavior
KSP should recognize cross-module interface bindings and not report false validation errors when:
- Implementations are annotated correctly.
- Modules are properly included.
- Dependencies are configured between modules.
Actual Behavior
KSP validation incorrectly claims a missing binding for an interface implemented in another module.
Workaround: Disabling validation via KOIN_CONFIG_CHECK = false for just domain module or whole project allows successful compilation and runtime execution.
Additional Context
-
Verifications:
- Interfaces are declared in
domain. - Implementations in
datause@Single(binds = [...]. - Root Koin module includes all submodules.
- KSP is configured in all modules.
- Interfaces are declared in
-
Logs: [ksp] [ERROR] Missing Definition for property 'authRepository : com.example.domain.AuthRepository' in 'com.example.domain.AuthInteractorImpl'.
Possible Causes
- KSP validation does not resolve cross-module dependencies correctly for Koin annotations.
- Koin KSP processor misses interface bindings declared in a separate module.
I'm facing the exact same issue in Koin 4.0.4 and Koin annotations 2.0.0
can you open issue in https://github.com/InsertKoinIO/koin-annotations/issues
Please check with 2.2 or 2.3 annotations