I'm having some issues trying to provide an Injection to an AndroidX fragment, and I'm not sure what the exact issue is, and how to fix it. The app refuses to build, giving the following error:
error: [Dagger/MissingBinding] java.util.Map<java.lang.Class<? extends androidx.fragment.app.Fragment>,javax.inject.Provider<dagger.android.AndroidInjector.Factory<? extends androidx.fragment.app.Fragment>>> cannot be provided without an @Provides-annotated method. Here's the method to provide the Injection in the Fragment:
private fun performDependencyInjection() = AndroidSupportInjection.inject(this) The fragment's parent Activity implements HasSupportFragmentInjector:
class MainActivity : BaseActivity(), MainMVPView, HasSupportFragmentInjector { @Inject internal lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment> ... override fun supportFragmentInjector() = dispatchingAndroidInjector } I'm completely lost as to where to solve this error from here. It doesn't appear that there is much current documentation for using Dagger2 with AndroidX.
I do feel it is important to note I enabled AndroidX and Jetifier through gradle.properties:
android.useAndroidX=true android.enableJetifier=true However, nothing had changed after a clean and rebuild of the project.
What is the proper way to provide an Injection to an AndroidX fragment using Dagger2?
Edit: For the record, this is on Dagger 2 version 2.19. If I switch to using 2.16, everything works fine.