Hi everyone, can you help me in fixing this issue ...
# koin
p
Hi everyone, can you help me in fixing this issue regarding koinViewModel-
org.koin.core.error.NoDefinitionFoundException: No definition found for type 'InterviewExpViewModel'. Check your Modules configuration and add missing type and/or qualifier!
Impl -
Copy code
@KoinViewModel
class InterviewExpViewModel(
    private val interviewExpRepository: InterviewExpRepository
) : ViewModel()
Copy code
@Composable
fun InterviewExpScreen() {
    val viewModel: InterviewExpViewModel = koinViewModel()
    viewModel.fetchInterviewExp()
}
Copy code
startKoin {
            androidContext(this@BaseApplication)
            modules(
                defaultModule,
                InterviewExpModule().module,
                BannerModule().module
            )
        }
koin version -
4.0.2
annotation -
2.0.0-RC1
👀 1
✅ 1
Generated file -
Copy code
@ExternalDefinition("com.idaten.feature_interview_exp.ui")
public fun Module.defineInterviewExpViewModel() : KoinDefinition<*> = viewModel() { _ -> com.idaten.feature_interview_exp.ui.InterviewExpViewModel(interviewExpRepository=get()) } 

public val _defaultModule : Module get() = module {
	defineInterviewExpViewModel()
}
public val defaultModule : org.koin.core.module.Module get() = _defaultModule
public fun org.koin.core.KoinApplication.defaultModule(): org.koin.core.KoinApplication = modules(defaultModule)
Also I am using same flow for different viewmodel, and its working fine for it.
a
seems to be in your default module, as an external definition. You should associate with a module (component scan)
p
Its working after adding component scan, Thanks. Yes before vm was in default module but now its in my specific module. But had a doubt how this works? Like we add component scan at module where we dont provide anything regarding viewmodel. So it scans through specified package and check for viewmodel and add it our specific module?
a
@ComponentScan allow to scan annotated classes for given package. Else it's falling back in default module. Perhaps a warning to show that your definition is in defaultModule.
🙌 1