title: Cannot inject a Fragment with Dagger 2
body: <p>I am able to inject Activities, BroadcastReceviers etc..., but when I try to inject a Fragment the same way I get the following exception:</p>
  
  <pre><code>.../AppComponent.java:8: error: [Dagger/MissingBinding] [dagger.android.AndroidInjector.inject(T)] java.util.Map&lt;java.lang.String,javax.inject.Provider&lt;dagger.android.AndroidInjector.Factory&lt;? extends android.support.v4.app.Fragment&gt;&gt;&gt; cannot be provided without an @Provides-annotated method.
      public abstract interface AppComponent extends dagger.android.AndroidInjector&lt;com.inepex.simpleclient.App&gt; {
                      ^
            java.util.Map&lt;java.lang.String,javax.inject.Provider&lt;dagger.android.AndroidInjector.Factory&lt;? extends android.support.v4.app.Fragment&gt;&gt;&gt; is injected at
                dagger.android.DispatchingAndroidInjector.&lt;init&gt;(…, injectorFactoriesWithStringKeys)
            dagger.android.DispatchingAndroidInjector&lt;android.support.v4.app.Fragment&gt; is injected at
                com.inepex.tracker.SimpleTrackerApp.fragmentInjector
            com.inepex.simpleclient.App is injected at
                dagger.android.AndroidInjector.inject(T)
  </code></pre>
  
  <p>I followed this description:
  <a href="https://code.luasoftware.com/tutorials/android/dagger2-injection-for-fragment/" rel="nofollow noreferrer">https://code.luasoftware.com/tutorials/android/dagger2-injection-for-fragment/</a></p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I would like to have a Fragment instance because I would likee to switch fragments like this:</p>
  
  <pre><code>Fragment fragment = new WelcomeFragment();
  
  FragmentManager fm = getSupportFragmentManager();
  FragmentTransaction transaction = fm.beginTransaction();
  transaction.replace(R.id.contentFragment, fragment);
  transaction.commit();
  </code></pre>
  
  <p>Injecting the Fragment:</p>
  
  <pre><code>class MainActivity : BaseActivity() {
  
      @Inject
      lateinit var welcomeFragment: WelcomeFragment
  
      override fun onCreate(savedInstanceState: Bundle?) {
          AndroidInjection.inject(this)
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          ButterKnife.bind(this)
      }
  }
  </code></pre>
  
  <p>Component:</p>
  
  <pre><code>@Component(modules = arrayOf(AndroidInjectionModule::class, AppModule::class, AbstractAppModule::class, AbstractLibModule::class, LibModule::class))
  @Singleton
  interface AppComponent : AndroidInjector&lt;App&gt; {
  
      @Component.Builder
      interface Builder {
          @BindsInstance
          fun application(application: App): Builder
  
          fun build(): AppComponent
      }
  }
  </code></pre>
  
  <p>Module:</p>
  
  <pre><code>@Module
  abstract class AbstractAppModule {
  
      @ContributesAndroidInjector
      internal abstract fun welcomeFragment(): WelcomeFragment
  
      @ContributesAndroidInjector
      internal abstract fun mainActivity(): MainActivity
  
      @ContributesAndroidInjector
      internal abstract fun onboardingActivity(): OnboardingActivity
  }
  </code></pre>
  
  <p>App:</p>
  
  <pre><code>open class SimpleTrackerApp : MultiDexApplication(),
          HasActivityInjector,
          HasServiceInjector,
          HasBroadcastReceiverInjector,
          HasSupportFragmentInjector {
  
  
      @Inject
      lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector&lt;Activity&gt;
  
      @Inject
      lateinit var dispatchingServiceInjector: DispatchingAndroidInjector&lt;Service&gt;
  
      @Inject
      lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector&lt;BroadcastReceiver&gt;
  
      @Inject
      lateinit var fragmentInjector: DispatchingAndroidInjector&lt;Fragment&gt;
  
      override fun activityInjector(): AndroidInjector&lt;Activity&gt; = dispatchingAndroidInjector
  
      override fun serviceInjector(): AndroidInjector&lt;Service&gt; = dispatchingServiceInjector
  
      override fun broadcastReceiverInjector(): AndroidInjector&lt;BroadcastReceiver&gt; =
              dispatchingBroadcastReceiverInjector
  
      override fun supportFragmentInjector(): DispatchingAndroidInjector&lt;Fragment&gt; = fragmentInjector
  </code></pre>