title: Unresolved inject method on Dagger2 method
body: <p>I'm trying to inject a set of Room components into a Repository which is itself injected into a ViewModel (which is in a fragment) using Dagger2.</p>
  
  <p>The code is as follows.</p>
  
  <p>Fragment:</p>
  
  <pre><code>class MyFragment : Fragment() {
      private var viewModel: MyViewModel? = null
  
      override fun onActivityCreated(savedInstanceState: Bundle?) {
          super.onActivityCreated(savedInstanceState)
          viewModel = ViewModelProviders.of(this).get(MyViewModel::class.java)
          viewModel!!.init()
          viewModel!!.getUser().observe(this, Observer&lt;MyClass?&gt; {...})
      }
      ...
  }
  </code></pre>
  
  <p>View Model:</p>
  
  <pre><code>class MyViewModel : ViewModel() {
  
      @Inject lateinit var myRepo: MyRepository
  
      private var instance: LiveData&lt;MyClass&gt;? = null
  
      fun init() {
          DaggerAppComponent.builder()
                  .build().daggerInject(this)
          if (this.instance != null) {
              return
          }
          instance = myRepo.getInstance()
      }
  }
  </code></pre>
  
  <p>My Repository:</p>
  
  <pre><code>@Singleton
  class MyRepository {
      @Inject lateinit var myDao: MyDao
      @Inject lateinit var executor: Executor
  
      init {
          DaggerAppComponent.builder().build().daggerInject(this)
      }
  }
  </code></pre>
  
  <p>Finally for my dagger classes I have two modules:</p>
  
  <pre><code>@Module(includes = [AndroidInjectionModule::class])
  abstract class AppModule {
  
      @Binds
      abstract fun application(app: MyApplication): MyApplication
  }
  
  
  @Module
  class DataModule {
  
      @Inject
      lateinit var application: MyApplication
  
      val myDatabase = Room.databaseBuilder(application, MyDatabase::class.java, "my-database").build()
  
      @Provides
      @Singleton
      fun provideRepository(): MyRepository {
          return MyRepository()
      }
  
      @Provides
      fun provideMyDao(): MyDao {
          return MyDao_Impl(myDatabase)
      }
  
      @Provides
      fun providesExecutor(): Executor {
          return Executors.newSingleThreadExecutor()
      }
  
  }
  </code></pre>
  
  <p>And my AppComponent:</p>
  
  <pre><code>@Singleton
  @Component(modules = [AppModule::class, DataModule::class])
  interface AppComponent : AndroidInjector&lt;MyApplication&gt; {
      fun daggerInject(viewModel: MyViewModel)
      fun daggerInject(myRepo: MyRepository)
  
      @Component.Builder
      abstract class Builder: AndroidInjector.Builder&lt;MyApplication&gt;()
  }
  </code></pre>
  
  <p>Dagger compiles fine, I can access the <code>DaggerAppComponent</code> and build it. However <code>dataModule</code> is inaccessible (inspecting the class shows it as private) as are the <code>daggerInject</code> methods I need to actually inject the dependencies. As a result I get the error:</p>
  
  <p><code>Unresolved reference: daggerInject</code></p>
  
  <p>How do I solve this?</p>