Dagger Hilt @ViewModelInject is deprecated how to use @ApplicationContext in @HiltViewModel

I’m using @ViewModelInject in my ViewModel as shown in below but now It’s deprecated so When I tried to use @HiltViewModel but I can’t use @ApplicationContext init.

So my question is How to use common dependency which I annotated with @InstallIn(SingletonComponent::class) in @HiltViewModel ?

How to use @ApplicationContext in @HiltViewModel , ViewModelComponent::class ?

My code Which Work fine with @ViewModelInject are below

1. AppModule()

annotation class SplashApiInterface

class AppModule() {
    internal var pref_name = Common.pref_name

    fun mySharedPreference(@ApplicationContext context: Context): SharedPreferences {
        return context.getSharedPreferences(pref_name, Context.MODE_PRIVATE)

    fun connectionDetector(@ApplicationContext context: Context): ConnectionDetector {
        return ConnectionDetector(context)

    fun myCompositeDisposable(): CompositeDisposable {
        return CompositeDisposable()

    fun mAPIServiceSplash(@ApplicationContext context: Context): ApiInterface {
        return ApiUtils.getAPIServiceSpl(context)



class SplashVModel @ViewModelInject constructor(@ApplicationContext val context: Context,
                                                val sharedPreferences: SharedPreferences,
                                                @SplashApiInterface val mAPIService: ApiInterface,
                                                val myCompositeDisposable: CompositeDisposable,
                                                var cd: ConnectionDetector
) : ViewModel() {
    // here I removed use cases of constructor value for brevity



So now if I use @HiltViewModel how to use SingletonComponent common function? Now If create ViewModelComponent::class then how to
use that common function again in this? So What should I do ? Do I
have to remove all common cases from SingletonComponent and use
individually in each ViewModel()?

Source: Android Questions