Open choongyouqi opened 3 years ago
In which Hilt component is the @InMemoryLogger
binding installed? It should be part of the SingletonComponent
it did work after converting the component to SingletonComponent
. but is SingletonComponent really the requirement to use DI with ViewModel?
I have created a branch demonstrating @ActivityScoped
@InMemoryLogger
working in hilt-2.28.3-alpha
https://github.com/choongyouqi/android-hilt/tree/feature/viewmodel_old
This is the sample using @HiltViewModel
in hilt-2.38.1
that I have to resort using SingletonComponent
https://github.com/choongyouqi/android-hilt/tree/feature/viewmodel_new
It doesn't need to be scoped or installed in the SingletonComponent
. You could have the qualifier applied to an unscoped type, for example.
If you take a look at the components hierarchy, ViewModelComponent
that is what @ViewModelInject
uses is a subcomponent of ActivityRetainedComponent
.
When I introduce a View Model as below,
it will hit the following build error:
used to be working fine back in the
@ViewModelInject
days