I updated room from 2.2.6
to 2.3.0
and started seeing weird errors in the compiled/generated java code at compile time. I do not see any errors in my .kt
files or in the generated .java
files in the directory ...build/tmp/kapt3/stubs/debug/...
I only see the compile-time error that breaks the build.
The full error I get:
error: You must annotate primary keys with @NonNull. "version" is nullable. SQLite considers this a bug and Room does not allow it. See SQLite docs for details: https://www.sqlite.org/lang_createtable.html
private java.lang.Integer version;
When I look at the generated .java
code I see that it is annotating it:
@org.jetbrains.annotations.Nullable()
@androidx.annotation.NonNull()
private java.lang.Integer version;
My Kotlin code is annotated as well:
import androidx.annotation.NonNull
...
@NonNull
var version: Int? = null
My code worked fine and is well tested and proven to work using room 2.2.6
. I only started having this problem after updating to room 2.3.0
.
Old dependencies.gradle
implementation "androidx.room:room-runtime:2.2.6"
kapt "androidx.room:room-compiler:2.2.6"
Updated dependencies.gradle
implementation "androidx.room:room-runtime:2.3.0"
kapt "androidx.room:room-compiler:2.3.0"
Any help is appreciated thanks!