Did something change in alpha07 for ViewModel and ...
# compose
y
Did something change in alpha07 for ViewModel and hilt usage? In an
AndroidEntrypoint
annotated activity, I'm now getting
has no zero argument constructor
when using the
viewModel()
composable to retrieve an instance (the ViewModel's constructor does have the
ViewModelInject
annotation)
Seems like
NavBackStackEntry
is overriding the
Copy code
ViewModelStoreOwnerAmbient
value, thus bypassing the hilt factory
y
Feels cumbersome having to pass the
defaultViewModelProviderFactory
everywhere, I guess I just have to create a
ViewModelFactoryAmbient
Anyway thanks for the help!
i
You'll definitely want to read that whole thread as Hilt definitely has some issued they're working through on their side when it comes to scoping their ViewModels correctly to anything other than an activity/fragment
y
Indeed, very interesting and informative thread, will find a way around until the issue is fixed. Thanks again