title: Dagger 2: Unable to find generated class in Intellij Idea (Kotlin)
body: <p>I was trying to write a application to understand spark and dagger 2. But was unable to use generated dagger files.</p>
  
  <p>There are multiple questions similar to this one, but I am not able to solve the problem using any of those.</p>
  
  <p>My project can be found at github <a href="https://github.com/pr-gupta/Pissarra" rel="nofollow noreferrer">here</a></p>
  
  <p>The build.gradle file looks like this</p>
  
  <pre><code>...
  apply plugin: 'kotlin-kapt'
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
      compile "com.sparkjava:spark-kotlin:$spark_kotlin_version"
      compile "org.slf4j:slf4j-log4j12:$slf4j_version"
      compile "com.google.dagger:dagger:$dagger_version"
      kapt "com.google.dagger:dagger-compiler:$dagger_version"
  
      testCompile group: 'junit', name: 'junit', version: '4.12'
  }
  ....
  </code></pre>
  
  <p>It's the <code>SparkSetup.kt</code> Class that I am trying to inject. Module and Component for this are present in <code>co.pissarra.util.dagger</code> package</p>
  
  <p>The contents of <code>SetupModule.kt</code> looks like this</p>
  
  <pre><code>@Module
  class SetUpModule {
      @Provides
      @Singleton
      fun provideSparkSetup() : SparkSetup {
          return SparkSetup()
      }
  }
  </code></pre>
  
  <p>And this is <code>AppComponent.kt</code> Class</p>
  
  <pre><code>@Singleton
  @Component(modules = arrayOf(SetUpModule::class))
  interface AppComponent {
      fun sparkSetup() : SparkSetup
  }
  </code></pre>
  
  <p>Ideally there should be a class by the name <code>DaggerAppComponent</code>, which infact is present in the build directory (both generated and classes). But this only works if I am not using <code>DaggerAppComponent</code> anywhere in the project. If I try using this, intellij idea gives the error that <code>Unresolved reference: DaggerAppComponent</code> and the project also fails to build.</p>
  
  <p>I would like to change the file <code>ContainerRunner.kt</code> and instead of calling <code>SparkSetup().init()</code> directly, I would like to have that done through DI.</p>