https://developer.android.com/training/dependency-injection/hilt-android#component-scopes Most important point to understand here is the "tier-like" system of scoping.
@Singleton
- Can inject into anything
ActivityRetainedScope
- Inject into everything except
Singleton
scoped objects - Ex: Can't inject into Application class
ActivityScope
- Inject into everything except
Singleton
andActivityRetainedComponent
scoped objects - Ex: Can't inject into Application or ViewModel
FragmentScope
- Inject into everything except
Singleton
,ActivityRetainedComponent and
ActivityScope` scoped objects - Ex: Can't inject into Activity, ViewModel or Application
- I think you get the idea. See the doc link: https://developer.android.com/training/dependency-injection/hilt-android#component-scopes