Hey guys I am getting this error using Koin for K...
# koin
b
Hey guys I am getting this error using Koin for KMP with annotations
Copy code
e: [ksp] --> Missing Definition type 'com.hero.domain.useCases.SuperheroUseCase' for 'com.hero.viewmodels.vms.SuperheroListingViewmodel'. Fix your configuration to define type 'SuperheroUseCase'.
I have added everything correctly i only added @KoinViewModel and its failing
Copy code
@KoinViewModel
class SuperheroListingViewmodel(
    private val superheroUseCase: SuperheroUseCase
) : ViewModel() 

@Module
@ComponentScan("com.hero.viewmodels")
class ViewmodelModule

val viewmodelModule = module {
    includes(
        listOf(
            ViewmodelModule().module
        )
    )
   // viewModelOf(::SuperheroListingViewmodel)
    viewModelOf(::SuperheroDetailsViewmodel)
    viewModelOf(::ChatViewModel)

}
Usecase
Copy code
@Single
class SuperheroUseCase(
    private val superheroRepository: SuperheroRepository
)
@Module
@ComponentScan("com.hero.domain")
class DomainModule


val domainModule = module {
    includes(
        listOf(
            DomainModule().module
        )
    )
}
Any thing incorrect here ?
p
Seems like you define an implementation for SuperHeroUseCase but you haven't bind it to koin or the automatic binding did not work.
👍 1
p
FROM
Copy code
@Single
class SuperheroUseCase(
    private val superheroRepository: SuperheroRepository
)
TO
Copy code
@Single
class SuperheroUseCaseImpl(
    private val superheroRepository: SuperheroRepository
): SuperheroUseCase

interface SuperheroUseCase
As @Pablichjenkov suggested, it will fix.
👍 1
b
@Pablichjenkov @Pedro Francisco de Sousa Neto No guys its there I have done both the implementation i gave is not full The issue is not with SuperHeroUseCase as it work when i use viewModelof() in DI
This works
i was trying @KoinViewModel annotation for KMP
p
When you open generated class by KSP, can you see the ViewModels declared from
ViewModelModule().module
? I'm asking this to confirm that your KSP + Koin Annotations is configured right. Because if don't, it will not generate the expected class and give this error that you mentioned initially.
b
yes it is generated @Pedro Francisco de Sousa Neto
no it is already working in other modules perfectly