Is there a known source of crashes from the 2.2 RC...
# koin
f
Is there a known source of crashes from the 2.2 RC where the savedstatehandle would not be passed properly ? My module declares a viewmodel as such:
Copy code
viewModel { ThingyVM(handle = get(), ...) }
When injecting it in my fragment, I properly use
Copy code
override val viewModel: ThingyVM by viewModel(state = { arguments ?: bundleOf() })
Sometimes, maybe like one launch out of 30, I get a crash,
Copy code
Caused by: org.koin.core.error.NoBeanDefFoundException: No definition found for class:'androidx.lifecycle.SavedStateHandle'. Check your definitions!
        at org.koin.core.scope.Scope.throwDefinitionNotFound(Scope.kt:277)
t
I think the state is supplied as a parameter. Therefore you should use
it.get()
to resolve it in your factory. But if this is the case, it's confusing that it's working most of the time. Have you been able to verify that the view model was actually created?
f
Yes, the VM works perfectly every other time. This is part of a refactor removing stateViewModel, so the actual VM has quite a bit of logic that would definitely be seen if it wasn't created. I'll check out it.get(), and see if I can still reproduce.
a
Well, I assume, this only crashes if your process is killed in the background by the system and it works fine in any other case. You can try to enable developer setting
Don't keep activities
and it should crash every time you put app to the background and return to it via recent app list.
f
It crashes as the fragment is shown, and the app is alive. I am considering it may be a race condition, the tests being done on an emulator that can struggle at times. I'll try to reproduce it with Don't keep activities.