title: How to @Inject an interface in @HiltViewModel?
body: <p>I am trying to run the following pieces of code.</p>
  <p>My ViewModel:</p>
  <pre><code>@HiltViewModel
  class SplashModel @Inject constructor(private val preferenceRep: PreferenceRep) : ViewModel() {
  
      private val _intoEvent = EventLiveData&lt;Unit&gt;()
      val intoEvent = _intoEvent.asLiveData()
  
      private val _homeEvent = EventLiveData&lt;Unit&gt;()
      val homeEvent = _homeEvent.asLiveData()
  
      init {
          viewModelScope.launch(Dispatchers.IO) {
              val isFirstTime = preferenceRep.isFirstTime().awaitValueOrError()
              delay(800L)
              if (isFirstTime)
                  _intoEvent post EventUnit
              else
                  _homeEvent post EventUnit
          }
      }
  }
  </code></pre>
  <p>My Fragment:</p>
  <pre><code>@AndroidEntryPoint
  class SplashFragment : Fragment() {
  
      private val splashModel by viewModels&lt;SplashModel&gt;()
  
      private val binding get() = splash!!
      private var splash: FragmentSplashBinding? = null
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View {
          splash = FragmentSplashBinding.inflate(inflater, container, false)
          return binding.root
      }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
          splashModel.intoEvent.observe(viewLifecycleOwner, EventObserver {
              navigate(R.id.nav_intro)
          })
          splashModel.homeEvent.observe(viewLifecycleOwner, EventObserver {
              navigate(R.id.nav_home)
          })
      }
  
      private fun navigate(id: Int) {
          findNavController().apply {
              popBackStack()
              navigate(id)
          }
      }
  
      override fun onDestroyView() {
          super.onDestroyView()
          splash = null
      }
  }
  </code></pre>
  <p>My App class:</p>
  <pre><code>@HiltAndroidApp
  class App : Application() {}
  </code></pre>
  <p>My Preference Repository:</p>
  <pre><code>interface PreferenceRep {
      fun isFirstTime(): FlowResult&lt;Boolean&gt;
  }
  </code></pre>
  <p>My Impl of Preference:</p>
  <pre><code>class PreferenceRepImpl @Inject constructor(private val dao: PreferenceDao) : PreferenceRep {
  
      override fun isFirstTime(): FlowResult&lt;Boolean&gt; {
          return dao.isFirstTime()
              .map { SuccessResult(it) }
              .catch { ErrorResult(RepositoryException(it)) }
      }
  }
  </code></pre>
  <p>My PreferenceDao:</p>
  <pre><code>interface PreferenceDao {
      fun isFirstTime(): Flow&lt;Boolean&gt;
  }
  </code></pre>
  <p>My Module:</p>
  <pre><code>@Module
  @InstallIn(SingletonComponent::class)
  abstract class PreferenceModule {
  
      @Provides
      @Singleton
      abstract fun preferenceDao(daoImpl: PreferenceDaoImpl): PreferenceDao
  
  }
  </code></pre>
  <p>My PreferenceDaoImpl:</p>
  <pre><code>class PreferenceDaoImpl @Inject constructor(@ApplicationContext private val context: Context) : PreferenceDao {
  
      private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
  
      @ExperimentalCoroutinesApi
      private val flowPref = FlowSharedPreferences(preferences)
  
      override fun isFirstTime(): Flow&lt;Boolean&gt; {
          return flowPref.boolean(KEY_FIRST_TIME, true).asFlow()
      }
  
      companion object {
          private const val KEY_FIRST_TIME = &quot;KEY_FIRST_TIME&quot;
      }
  }
  </code></pre>
  <p>And the exception:</p>
  <pre><code>error: [Dagger/MissingBinding] xxx.xxx.xxx.utils.preferences.PreferenceRep cannot be provided without an @Provides-annotated method.
    public abstract static class SingletonC implements App_GeneratedInjector,
                           ^
        xxx.xxx.xxx.utils.preferences.PreferenceRep is injected at
            xxx.xxx.xxx.utils.models.SplashModel(preferenceRep)
        xxx.xxx.xxx.utils.models.SplashModel is injected at
            xxx.xxx.xxx.utils.models.SplashModel_HiltModules.BindsModule.binds(arg0)
        @dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map&lt;java.lang.String,javax.inject.Provider&lt;androidx.lifecycle.ViewModel&gt;&gt; is requested at
            dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [xxx.xxx.xxx.utils.App_HiltComponents.SingletonC ? xxx.xxx.xxx.utils.App_HiltComponents.ActivityRetainedC ? xxx.xxx.xxx.utils.App_HiltComponents.ViewModelC]
  </code></pre>
  <p>I searched for a solution, but did not find anything how to deal with annotations within the <code>PreferenceRep</code> interface. By the way I am trying to get it done like in this sample project: <a href="https://github.com/android/architecture-samples" rel="nofollow noreferrer">https://github.com/android/architecture-samples</a> but using Dagger Hilt.</p>