1

I am converting an old app to HILT however I am having some difficulties with an interface.

fragment having the issue

@AndroidEntryPoint
class mainFragment : baseFragment(), Listener

My fragment implements a interface called Listener

viewModel

@HiltViewModel
class PviewModel @Inject constructor @Inject constructor(val listener: Listener) :  baseViewModel() 

I found what I thought was a possible solution here How to Bind/Provide Activity or Fragment with Hilt? but it gives me an error about providing the fragment still

here is the module

@Module
@InstallIn(FragmentComponent::class)
object FragmentModule {

    @Provides
    fun provideCallback(fragment: mainFragment) =
        fragment as Listener
}

Error itself error: [Dagger/MissingBinding] ....mainFragment cannot be provided without an @Inject constructor or an @Provides-annotated method.

android
  • 135
  • 1
  • 6

0 Answers0