title: Inject Adapter class to Fragment using Dagger2
body: <p>I have followed Android Architecture Blueprints Dagger2 for dependency injection: <a href="https://github.com/googlesamples/android-architecture/tree/todo-mvp-dagger" rel="nofollow noreferrer">URL</a></p>
  
  <p><strong>Now I want to inject Adapter to my Fragment class:</strong></p>
  
  <pre><code>@ActivityScoped
  class MainFragment @Inject
  constructor(): DaggerFragment(), ArtistClickCallback {
  
      @Inject lateinit var adapter : ArtistAdapter 
  }
  </code></pre>
  
  <p><strong>Main Module class:</strong></p>
  
  <pre><code>@Module
  abstract class MainModule {
      @FragmentScoped
      @ContributesAndroidInjector(modules = [MainFragmentModule::class])
      internal abstract fun mainFragment(): MainFragment
  
      @Binds
      internal abstract fun bindArtistClickCallback(mainFragment: MainFragment) : ArtistClickCallback
  }
  </code></pre>
  
  <p><strong>MainFragmentModule:</strong></p>
  
  <pre><code>@Module
  class MainFragmentModule {
  
      @Provides
      fun provideArtistAdapter() = ArtistAdapter()
  }
  </code></pre>
  
  <p><strong>And this is my adapter class:</strong></p>
  
  <pre><code> class ArtistAdapter @Inject constructor(
    private val artistClickCallback : ArtistClickCallback
  ) : PagedListAdapter&lt;LastFmArtist, RecyclerView.ViewHolder&gt;(POST_COMPARATOR)
  </code></pre>
  
  <p><strong>When I build the project I get following Kotlin compiler error:</strong></p>
  
  <pre><code>error: [Dagger/DependencyCycle] Found a dependency cycle:
  public abstract interface AppComponent extends dagger.android.AndroidInjector&lt;com.sample.android.lastfm.LastFmApp&gt; {
                  ^
        com.sample.android.lastfm.ui.main.MainFragment is injected at
  
  
  com.sample.android.lastfm.ui.main.MainModule.bindArtistClickCallback$app_debug(mainFragment)
    com.sample.android.lastfm.ArtistClickCallback is injected at
        com.sample.android.lastfm.ui.main.ArtistAdapter.artistClickCallback
    com.sample.android.lastfm.ui.main.ArtistAdapter is injected at
        com.sample.android.lastfm.ui.main.MainFragment.adapter
    com.sample.android.lastfm.ui.main.MainFragment is injected at
        com.sample.android.lastfm.ui.main.MainActivity.mainFragment
    com.sample.android.lastfm.ui.main.MainActivity is injected at
        dagger.android.AndroidInjector.inject(T) [com.sample.android.lastfm.di.AppComponent → com.sample.android.lastfm.di.ActivityBindingModule_MainActivity$app_debug.MainActivitySubcomponent]
  </code></pre>
  
  <p>Can you suggest me how to solve this problem?</p>
  
  <p>Codes can be found at <a href="https://github.com/Ali-Rezaei/Last.fm-MVI/tree/inject_adapter" rel="nofollow noreferrer">URL</a></p>