title: Dagger-Hilt @ViewModelInject sharedViewModel not injecting into fragment
body: <p>I'm trying to make a shared injected view model between a fragment and an activity using the <a href="https://developer.android.com/training/dependency-injection/hilt-jetpack#viewmodels" rel="noreferrer">Jetpack tutorial</a>.</p>
  <p>The shared view model is successfully injected into the parent MyActivity but when the child is rendered, the application crashes due to dependency injection failure. I have provided the code below that created the issue.</p>
  <p>Providing the Session Manager:</p>
  <pre><code>@InstallIn(ApplicationComponent::class)
  @Module
  class AppModule {
      @Provides
      @Singleton
      fun provideSessionManager(
          networkClient: NetworkClient
      ): SessionManager {
          return SessionManager(networkClient)
      }
  }
  </code></pre>
  <p>To be injected into the Shared View Model:</p>
  <pre><code>class SharedViewModel @ViewModelInject constructor(
      private var sessionManager: SessionManager
  ) : ViewModel() {
  
      var name = MutableLiveData&lt;String&gt;(&quot;Shared View Model&quot;)
  }
  </code></pre>
  <p>And is used by both a parent activity and child fragment.</p>
  <pre><code>class MyActionFragment() : Fragment() {
      private val viewModel: SharedViewModel by viewModels()
      override fun onActivityCreated(savedInstanceState: Bundle?) {
         super.onActivityCreated(savedInstanceState)
         Timber.d(&quot;View Model Name 1: ${viewModel.name.value}&quot;) // This line crashes
      }
  }
  </code></pre>
  <pre><code>class MyActivity : AuthenticatedBaseActivity() {
      private val viewModel: SharedViewModel by viewModels()
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          Timber.d(&quot;View Model Name 2: ${viewModel.name.value}&quot;) // This line prints
      }
  }
  </code></pre>
  <p>However, when the code is run, notice the activity created the ViewModel and accessed its values, but when the fragment tried to do the same, the application crashes:</p>
  <pre><code>**D/MyActivity: View Model Name 2: Shared View Model**
  E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.xxx.xxx, PID: 16630
      java.lang.RuntimeException: Cannot create an instance of class com.xxx.xxx.ui.main.SharedViewModel
          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.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 com.xxx.xxx.ui.main.MyActionFragment.getViewModel(Unknown Source:2)
          at com.xxx.xxx.ui.main.MyActionFragment.onActivityCreated(**MyActionFragment.kt:140**)
          at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2718)
  </code></pre>
  <p>Additionally, when I remove the Hilt dependency injected <code>sessionManager</code> the fragment and view model are created without an issue.</p>
  <p>Followed <a href="https://stackoverflow.com/questions/62659094/dagger-hilt-viewmodelinject-is-not-injecting-myviewmodel-and-crash">this post</a> with no luck.</p>
  <p>Any help on Hilt view model dependency injection with a shared model would be extremely appreciated!! Thanks!</p>