dependencies {
def room_version = "2.4.0"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
}
检查是否正确注释了@Entity和@PrimaryKey注解,并使用正确的数据类型。
如果在编译时出现了“Unresolved reference: RoomDatabase”错误,则需要将以下依赖库添加到module级别的build.gradle文件中:
dependencies {
def room_version = "2.4.0"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
}