title: How install view model in fragmentComponent with Hilt injection?
body: <p>I want scope ViewModel and it's dependencies by Fragment not activity,</p>
  <pre><code>interface MarsRepository {
      suspend fun getProperties(): List&lt;Mars&gt;
  }
  
  
  
  @Module
  @InstallIn(FragmentComponent::class)
  class MarsRepositoryModule {
      
      @Provides
      fun bindRemoteMarsDataSource(): MarsRepository{
          return RemoteMarsStorageImp()
      }
  }
  
  
  
  class MarsViewModel @ViewModelInject constructor(private val repository: MarsRepository): ViewModel()
  
  
  
  @AndroidEntryPoint
  class MarsFragment: Fragment() {
      
      val viewModel by viewModels&lt;MarsViewModel&gt;()
  }
  </code></pre>
  <p>But I got this</p>
  <pre><code>/app/build/generated/source/kapt/debug/com/Sample/bestcase/DevByteApplication_HiltComponents.java:111: error: [Dagger/MissingBinding] com.Sample.domain.repository.MarsRepository cannot be provided without an @Provides-annotated method.
    public abstract static class SingletonC implements DevByteApplication_GeneratedInjector,
                           ^
        javax.inject.Provider&lt;com.Sample.domain.repository.MarsRepository&gt; is injected at
            com.Sample.bestcase.features.mars.MarsViewModel_AssistedFactory(repository)
        com.Sample.bestcase.features.mars.MarsViewModel_AssistedFactory is injected at
            com.Sample.bestcase.features.mars.MarsViewModel_HiltModule.bind(factory)
        java.util.Map&lt;java.lang.String,javax.inject.Provider&lt;androidx.hilt.lifecycle.ViewModelAssistedFactory&lt;? extends androidx.lifecycle.ViewModel&gt;&gt;&gt; is injected at
            androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule.provideFactory(…, viewModelFactories)
        @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory java.util.Set&lt;androidx.lifecycle.ViewModelProvider.Factory&gt; is requested at
            dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories.ActivityEntryPoint.getActivityViewModelFactory() [com.Sample.bestcase.DevByteApplication_HiltComponents.SingletonC → com.Sample.bestcase.DevByteApplication_HiltComponents.ActivityRetainedC → com.Sample.bestcase.DevByteApplication_HiltComponents.ActivityC]
    The following other entry points also depend on it:
        dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories.FragmentEntryPoint.getFragmentViewModelFactory() [com.Sample.bestcase.DevByteApplication_HiltComponents.SingletonC → com.Sample.bestcase.DevByteApplication_HiltComponents.ActivityRetainedC → com.Sample.bestcase.DevByteApplication_HiltComponents.ActivityC → com.Sample.bestcase.DevByteApplication_HiltComponents.FragmentC]
  </code></pre>
  <p>It just works if installed by ActivityComponent</p>
  <pre><code>@Module
  @InstallIn(ActivityComponent::class)
  class MarsRepositoryModule { 
      @Provides
      fun bindRemoteMarsDataSource(): MarsRepository{
          return RemoteMarsStorageImp()
      }
  }
  </code></pre>
  <p>As I track the code It uses DefaultActivityViewModelFactory instead of DefaultFragmentViewModelFactory</p>
  <pre><code> /**
       * Hilt Modules for providing the activity level ViewModelFactory
       */
      @Module
      @InstallIn(ActivityComponent.class)
      public abstract static class ActivityModule {
  
          @NonNull
          @Multibinds
          abstract Map&lt;String, ViewModelAssistedFactory&lt;? extends ViewModel&gt;&gt; viewModelFactoriesMap();
  
          @Provides
          @IntoSet
          @NonNull
          @DefaultActivityViewModelFactory
          static ViewModelProvider.Factory provideFactory(
                  @NonNull Activity activity,
                  @NonNull Application application,
                  @NonNull Map&lt;String, Provider&lt;ViewModelAssistedFactory&lt;? extends ViewModel&gt;&gt;&gt;
                          viewModelFactories) {
              // Hilt guarantees concrete activity is a subclass of ComponentActivity.
              SavedStateRegistryOwner owner = (ComponentActivity) activity;
              Bundle defaultArgs = activity.getIntent() != null
                      ? activity.getIntent().getExtras() : null;
              SavedStateViewModelFactory delegate =
                      new SavedStateViewModelFactory(application, owner, defaultArgs);
              return new HiltViewModelFactory(owner, defaultArgs, delegate, viewModelFactories);
          }
      }
  
      /**
       * Hilt Modules for providing the fragment level ViewModelFactory
       */
      @Module
      @InstallIn(FragmentComponent.class)
      public static final class FragmentModule {
  
          @Provides
          @IntoSet
          @NonNull
          @DefaultFragmentViewModelFactory
          static ViewModelProvider.Factory provideFactory(
                  @NonNull Fragment fragment,
                  @NonNull Application application,
                  @NonNull Map&lt;String, Provider&lt;ViewModelAssistedFactory&lt;? extends ViewModel&gt;&gt;&gt;
                          viewModelFactories) {
              Bundle defaultArgs = fragment.getArguments();
              SavedStateViewModelFactory delegate =
                      new SavedStateViewModelFactory(application, fragment, defaultArgs);
              return new HiltViewModelFactory(fragment, defaultArgs, delegate, viewModelFactories);
          }
  
          private FragmentModule() {
          }
      }
  </code></pre>