title: Android Room Persistence library and Kotlin
body: <p>I am trying to write a simple app using Kotlin and <a href="https://developer.android.com/topic/libraries/architecture/room.html" rel="nofollow noreferrer">Room Persistence Library</a>.
  I followed <a href="https://codelabs.developers.google.com/codelabs/android-persistence" rel="nofollow noreferrer">the tutorial</a> in the Android Persistence codelab.</p>
  <p>Here is my <code>AppDatabase</code> class in Kotlin:</p>
  <pre><code>@Database(entities = arrayOf(User::class), version = 1)
  abstract class AppDatabase : RoomDatabase() {
      abstract fun userModel(): UserDao
  
      companion object {
          private var INSTANCE: AppDatabase? = null
          @JvmStatic fun getInMemoryDatabase(context: Context): AppDatabase {
              if (INSTANCE == null) {
                  INSTANCE = Room.inMemoryDatabaseBuilder(context.applicationContext, AppDatabase::class.java).allowMainThreadQueries().build()
              }
              return INSTANCE!!
          }
  
          @JvmStatic fun destroyInstance() {
              INSTANCE = null
          }
      }
  }
  </code></pre>
  <p>But when I tried to run the app, it crashes immediately.
  Here is the crash log:</p>
  <pre><code>Caused by: java.lang.RuntimeException: cannot find implementation for com.ttp.kotlin.kotlinsample.room.AppDatabase. AppDatabase_Impl does not exist
      at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:90)
      at android.arch.persistence.room.RoomDatabase$Builder.build(RoomDatabase.java:340)
      at com.ttp.kotlin.kotlinsample.room.AppDatabase$Companion.getInMemoryDatabase(AppDatabase.kt:19)
      at com.ttp.kotlin.kotlinsample.MainKotlinActivity.onCreate(MainKotlinActivity.kt:28)
      at android.app.Activity.performCreate(Activity.java:6272)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) 
      at android.app.ActivityThread.access$900(ActivityThread.java:157) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
  </code></pre>
  <p>It looks like the class <code>AppDatabase_Impl</code> wasn't autogenerated. I checked the original java app downloaded from codelab and found that <code>AppDatabase_Impl</code> was autogenerated.</p>
  <p>Kotlin version: <code>1.1.2-3</code><br />
  Room version: <code>1.0.0-alpha1</code></p>
  <p>Is there anyone experienced with this?</p>
  <p><strong>Edit:</strong>
  Using <code>kapt</code> solves my problem. In my case, I have to replace <code>annotationProcessor</code> with <code>kapt</code>.</p>