title: Android: ViewModel injected with hilt throws has no zero argument constructor"
body: <p>I migrated my app from dagger2 to hilt manually. i didn't face any compilation or build errors.
  but when I try to run my app, it crashes at the splash screen with this stack:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: pfe.usdb.dictili, PID: 7815
  java.lang.RuntimeException: Unable to start activity ComponentInfo{pfe.usdb.dictili/pfe.usdb.dictili.view.auth.SplashScreen}: java.lang.RuntimeException: Cannot create an instance of class pfe.usdb.dictili.viewmodel.auth.AuthVModel
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:223)
      at android.app.ActivityThread.main(ActivityThread.java:7656)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
   Caused by: java.lang.RuntimeException: Cannot create an instance of class pfe.usdb.dictili.viewmodel.auth.AuthVModel
      at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:221)
      at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:278)
      at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.java:106)
      at androidx.hilt.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:74)
      at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69)
      at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:185)
      at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)
      at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:54)
      at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:41)
      at pfe.usdb.dictili.view.auth.SplashScreen.getViewModel(Unknown Source:2)
      at pfe.usdb.dictili.view.auth.SplashScreen.onCreate(SplashScreen.kt:46)
      at android.app.Activity.performCreate(Activity.java:8000)
      at android.app.Activity.performCreate(Activity.java:7984)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:223) 
      at android.app.ActivityThread.main(ActivityThread.java:7656) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
   Caused by: java.lang.InstantiationException: java.lang.Class&lt;pfe.usdb.dictili.viewmodel.auth.AuthVModel&gt; has no zero argument constructor
      at java.lang.Class.newInstance(Native Method)
      at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:219)
      at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:278) 
      at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.java:106) 
      at androidx.hilt.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:74) 
      at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69) 
      at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:185) 
      at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150) 
      at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:54) 
      at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:41) 
      at pfe.usdb.dictili.view.auth.SplashScreen.getViewModel(Unknown Source:2) 
      at pfe.usdb.dictili.view.auth.SplashScreen.onCreate(SplashScreen.kt:46) 
      at android.app.Activity.performCreate(Activity.java:8000) 
      at android.app.Activity.performCreate(Activity.java:7984) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:223) 
      at android.app.ActivityThread.main(ActivityThread.java:7656) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
  </code></pre>
  <p>it says it cannot create an instance of that viewmodel because it doesn't have a zero argument constructor, but:
  1- my viewmodel class is injected with hilt (BaseViewModel is abstract):</p>
  <pre><code>class AuthVModel @ViewModelInject constructor(
  private val sharedPreferences: PreferencesRepository,
  private val authRepository: AuthRepository
  ) : BaseViewModel()
  </code></pre>
  <p>2- my activity is annotated with AndroidEntryPoint (BaseActivity is abstract):</p>
  <pre><code>@AndroidEntryPoint
  class SplashScreen : BaseActivity() {
  
  private val viewModel: AuthVModel by viewModels()
  </code></pre>
  <p>3- the repositories the viewmodel is depending on are injected properly and android studio 4.1.1 is showing the injection icon on the left:</p>
  <pre><code>class AuthRepository @Inject constructor(
  @NonAuthenticatedAuthenticationService private val unauthorizedService: AuthService,
  @AuthenticatedAuthenticationService private val authorizedService: AuthService
  ) 
  
  class PreferencesRepository @Inject constructor(
  private val sharedPreferences: SharedPreferences
  )
  </code></pre>
  <p>I don't know what's happening here, this is not my first time working with this, since I built some apps recently just like this (some code is 100% copied from these projects).</p>