Room Persistence Library run time exception when calling Rooms inMemoryBuilder method

前端 未结 8 926
不思量自难忘°
不思量自难忘° 2020-12-09 16:13

When following the tutorial for setting up the Room persistence library I run in to this error when testing on an Android device.

java.lang.RuntimeException: cannot

相关标签:
8条回答
  • 2020-12-09 16:19

    In my case I have change scheme but forgot to change version number.

    @Database(entities = {Task1.class, Task2.class}, version = 2)

    0 讨论(0)
  • 2020-12-09 16:20

    For kotlin

     //Room
    implementation "android.arch.persistence.room:runtime:1.0.0"
    //Room annotation processor
    kapt "android.arch.persistence.room:compiler:1.0.0"
    
    apply plugin: 'kotlin-kapt'
    
    0 讨论(0)
  • 2020-12-09 16:21

    Rule of thumb when using Kotlin:

    Replace your annotationProcessor dependencies with kapt. Also, include apply plugin: 'kotlin-kapt' in your app's build.gradle.

    0 讨论(0)
  • 2020-12-09 16:23

    Have a look on this thread

    The solution is to replace :

    annotationProcessor "android.arch.persistence.room:compiler:VERSION"
    

    with :

    kapt "android.arch.persistence.room:compiler:VERSION"
    
    0 讨论(0)
  • 2020-12-09 16:24

    change the annotationProcessor from annotationProcessor 'android.arch.persistence.room:runtime:1.1.0' to annotationProcessor 'android.arch.persistence.room:compiler:1.1.0'

    0 讨论(0)
  • 2020-12-09 16:27

    Had the same issue with

    • gradle 3.2.0-alpha09
    • koltin 1.2.31

    Due the removal of apply plugin: 'kotlin-kapt' and other buggy stuff.. I had to downgrade to kotlin 1.1.60 to make it work. Then use:

    apply plugin: 'kotlin-kapt'
    
    dependencies {
        ...
        implementation 'android.arch.persistence.room:runtime:1.0.0'
        kapt "android.arch.persistence.room:compiler:1.0.0"
    }
    

    an other option would be to write the DB entities/DAOs and DataBase in Java instead.

    0 讨论(0)
提交回复
热议问题