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
In my case I have change scheme but forgot to change version number.
@Database(entities = {Task1.class, Task2.class}, version = 2)
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'
Replace your annotationProcessor dependencies with kapt. Also, include apply plugin: 'kotlin-kapt' in your app's build.gradle.
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"
change the annotationProcessor from annotationProcessor 'android.arch.persistence.room:runtime:1.1.0' to annotationProcessor 'android.arch.persistence.room:compiler:1.1.0'
Had the same issue with
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.