Unable to read and write data to the database after updating room database dependency version

33 Views Asked by At

After updating the dependency version of RoomDB, I am unable to read and write data to the database.

Before

implementation 'androidx.room:room-runtime:2.2.5'
kapt 'androidx.room:room-compiler:2.2.5'
implementation 'androidx.room:room-rxjava2:2.2.5'

After

implementation 'androidx.room:room-runtime:2.5.2'
kapt 'androidx.room:room-compiler:2.5.2'
implementation 'androidx.room:room-rxjava2:2.5.2'

This error occurs from version 2.3.0-alpha03 and onwards. There is no errors displayed in logcat so I don't know what is going on.

Any help would be appreciated

1

There are 1 best solutions below

0
Hai Hack On

Change from

@NonNull
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id")
var id: Int? = null

to

@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id")
var id: Int = 0

fixed my issue

Since 2.3.0, the RoomDb library is written in the Kotlin, which is probably the reason.