Closed xyz-fly closed 2 years ago
Is there more to that stack trace? I would guess what is going on is that you may be trying to get the model at some point other than onCreate() which is creating the view model at a time in the lifecycle that it isn't allowed to be created in. This likely isn't a Hilt issue but just an issue with when you are trying to create the ViewModel.
Closing this for now, but feel free to reopen if you are still having this issue and have more information you can provide.
androidx.savedstate.SavedStateRegistry.runOnNextRecreation (SavedStateRegistry.java:168) androidx.lifecycle.SavedStateHandleController.tryToAddRecreator (SavedStateHandleController.java:109) androidx.lifecycle.SavedStateHandleController.create (SavedStateHandleController.java:71) androidx.lifecycle.AbstractSavedStateViewModelFactory.create (AbstractSavedStateViewModelFactory.java:67) androidx.lifecycle.AbstractSavedStateViewModelFactory.create (AbstractSavedStateViewModelFactory.java:84) dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create (HiltViewModelFactory.java:109) androidx.lifecycle.ViewModelProvider.get (ViewModelProvider.kt:171) androidx.lifecycle.ViewModelProvider.get (ViewModelProvider.kt:139) androidx.lifecycle.ViewModelLazy.getValue (ViewModelLazy.kt:44) androidx.lifecycle.ViewModelLazy.getValue (ViewModelLazy.kt:31) com.leon.ui.SplashActivity.getModel (SplashActivity.kt:36)
the 36 line code is:
private val model: SplashActivityModel by viewModels()
the all code is: `@AndroidEntryPoint class SplashActivity : AppCompatActivity() {
}`
the version is 2.40.4