My app database class
@Database(entities = {Detail.class}, version = Constant.DATABASE_VERSION)
public abstract class AppDatabase extends RoomDatabase {
For Kotlin Developers
if you checked Dao and Entity and also used Kapt and there is no problem, I guess there is a problem with your kotlin version if you are using kotlin 1.4 and above. update Room to last version from this link.
2.3.0-alpha03 solved my problem.
It is not just about updating your dependencies. Make sure all your Room dependencies have the same version.
implementation 'android.arch.persistence.room:rxjava2:1.1.0-alpha2'
implementation 'android.arch.persistence.room:runtime:1.1.0-alpha2'
annotationProcessor "android.arch.persistence.room:compiler:1.1.0-alpha2"
In the sample snippet above, all my Room dependencies have the same version 1.1.0-alpha2
The issue is more around the correct library that is not included in the gradle build. I had a similar issue and added the missing
testImplementation "android.arch.persistence.room:testing:$room_version
For Kotlin Developers
Use this:
implementation "android.arch.persistence.room:runtime:1.0.0"
kapt "android.arch.persistence.room:compiler:1.0.0"
And add apply plugin: 'kotlin-kapt'
to the top of the app level build.gradle
.
For Java Developers
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
make sure to add correct dependency for room in build.gradle
ext {
roomVersion = '2.1.0-alpha06'
}
// Room components
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.room:room-ktx:$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
And below line at the top-
apply plugin: 'kotlin-kapt'
In my case, I was testing the connectivity for room database and I have put the testing class inside the directory which I have created inside the AndroidTest folder. I have moved it out of the custom directory, then it worked pretty well.