title: Kotlin + Room : java.lang.IllegalArgumentException: void cannot be converted to an Element
body: <p>I am trying to add Room in my project which is Java + Kotlin, but when I try to compile the project, it fails on <code>:app:kaptDebugKotlin</code> with following error:</p>
  
  <pre><code>    e: java.lang.IllegalStateException: failed to analyze: java.lang.IllegalArgumentException: void cannot be converted to an Element
      at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:57)
      at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:138)
      at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
      at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:58)
      at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:103)
      at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
      at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:386)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:96)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:889)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:96)
      at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:916)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:888)
      at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:385)
      at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
      at sun.rmi.transport.Transport$1.run(Transport.java:200)
      at sun.rmi.transport.Transport$1.run(Transport.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.IllegalArgumentException: void cannot be converted to an Element
      at com.google.auto.common.MoreTypes$AsElementVisitor.defaultAction(MoreTypes.java:532)
      at com.google.auto.common.MoreTypes$AsElementVisitor.defaultAction(MoreTypes.java:527)
      at javax.lang.model.util.SimpleTypeVisitor6.visitNoType(SimpleTypeVisitor6.java:226)
      at com.sun.tools.javac.code.Type$JCVoidType.accept(Type.java:1736)
      at com.google.auto.common.MoreTypes.asElement(MoreTypes.java:524)
      at com.google.auto.common.MoreTypes.asTypeElement(MoreTypes.java:553)
  </code></pre>
  
  <p>Here are the versions I am using:</p>
  
  <pre><code>kotlin_version = '1.1.51'
  room library version = '1.0.0'
  android build tool = '3.0.1'
  </code></pre>
  
  <p>below things I have added in my gradle for Room:</p>
  
  <pre><code>kapt "com.android.databinding:compiler:3.0.1"
  
  //Room
  implementation "android.arch.persistence.room:runtime:1.0.0"
  kapt "android.arch.persistence.room:compiler:1.0.0"
  implementation "android.arch.persistence.room:rxjava2:1.0.0"
  </code></pre>
  
  <p>I have also added <code>apply plugin: 'kotlin-kapt'</code> in my build.gradle.</p>
  
  <p>Here's how I have implemented Room Library:</p>
  
  <pre><code>RoomDatabase.kt
  
  @Database(entities = arrayOf(ProductTest::class), version = CartDatabase.DATABASE_VERSION)
  abstract class CartDatabase : RoomDatabase() {
  
      companion object {
          const val DATABASE_VERSION = 1
          const val DATABASE_NAME = "sall_customer_db"
      }
  
      abstract var cartRepositoryImpl: CartRepositoryImpl
  }
  
  ProductTest.kt
  @Entity
  data class ProductTest(
          @PrimaryKey
          @ColumnInfo(name = "id")
          var productId: Int,
          @ColumnInfo(name = "name")
          var productName: String
  )
  
  CartRepositoryImpl.kt
  @Dao
  interface CartRepositoryImpl : CartRepository {
      @Insert(onConflict = OnConflictStrategy.REPLACE)
      override fun addToCart(product: ProductTest): Long
  }
  </code></pre>
  
  <p>I have just coded this without using it anywhere &amp; tried to compile, but it fails. It compiles fine if I comment out the Room stuff from gradle &amp; code but fails with just the above code.</p>
  
  <p>Have already tried cleaning the project but it didn't help. Am I missing something here? Please help me out here.</p>
  
  <p><strong>Edit</strong> I created the new demo project to check &amp; I am also facing the same compilation error there. The Room related code is same as above, here I am adding the full build.gradle from my demo:</p>
  
  <p><strong>Project level gradle:</strong></p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      ext.kotlin_version = '1.1.51'
      repositories {
          google()
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.0.0'
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
      }
  }
  
  
  // Versions
  ext {
      support_library_version = '27.0.0'
      play_services_version = '11.6.2'
      retrofit_version = '2.3.0'
      arch_components_version = '1.0.0'
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p><strong>app module's gradle</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  
  apply plugin: 'kotlin-android-extensions'
  
  apply plugin: 'kotlin-kapt'
  
  android {
      compileSdkVersion 26
      defaultConfig {
          applicationId "com.abc.kotlinroomdemo"
          minSdkVersion 14
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
  
      implementation 'com.android.support:appcompat-v7:26.1.0'
      implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  
      // RxJava2
      implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
      implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
  
      //Room
      implementation "android.arch.persistence.room:runtime:$arch_components_version"
      implementation "android.arch.persistence.room:rxjava2:$arch_components_version"
      kapt "android.arch.persistence.room:compiler:$arch_components_version"
  
      //Dagger 2
      //compile 'com.google.dagger:dagger-android:2.10'
      //kapt 'com.google.dagger:dagger-android-processor:2.10'
      //compileOnly 'com.google.dagger:dagger:2.10'
      //implementation 'com.google.dagger:dagger:2.13'
      //kapt 'com.google.dagger:dagger-compiler:2.13'
      //provided 'javax.annotation:jsr250-api:1.0'
  
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.1'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  }
  </code></pre>