I have a ViewModel that is covered with tests (was working fine). I had to inherit from AndroidViewModel since I needed access to a Context.
When I made the change, all my test are failing with the following error:
Can't resolve Application instance. Please use androidContext() function in your KoinApplication configuration. org.koin.android.error.MissingAndroidContextException: Can't resolve Application instance. Please use androidContext() function in your KoinApplication configuration.
My ViewModel definition in my Koin module:
viewModel { (formFactor: FormFactor, orientation: ProductOrientation) ->
MyViewModel(
androidApplication(),
formFactor,
orientation,
)
}
My Koin initialisation:
startKoin {
androidContext(this@MyMainApplication)
fragmentFactory()
modules(appModules)
}
The only change I introduces is adding androidApplication() argument to support the switch from ViewModel to AndroidViewModel