Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Room Database - Unresolved reference @Entity and other annotations

I am using Android Room Persistence library (v.1.0.0-alpha1) in my app. Although it is working fine, when I open model class (Kotlin Data class) in Android studio, it shows Unresolved reference for all annotations used for Room database like @Entity, @ColumnInfo etc. I tried changing version of arch library to 1.0.0-alpha5 but result was same.

In Lint inspection it is showing Remove deprecated symbol import for all imported annotations.AS was not showing this error previously.

How can I resolve this issue

Edit Following are imports I have added in my build.gradle

compile "android.arch.persistence.room:runtime:1.0.0-alpha5"

compile "android.arch.persistence.room:rxjava2:1.0.0-alpha5"

annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha5"

kapt "android.arch.persistence.room:compiler:1.0.0-alpha5"
like image 461
silwar Avatar asked Aug 17 '17 10:08

silwar


People also ask

Is room database deprecated?

This method is deprecated. Called by Room when it is initialized. Convenience method to query the database with arguments. Wrapper for SupportSQLiteDatabase. query .

What is the difference between SQLite and room database?

Realm is an easy-to-use, open-source alternative to SQLite. The key difference between the two is that Realm is an object database management system, while SQLite is a relational database management system. Realm is often used to replace SQLite. Let's take a closer look at both databases.

What is Androidx room?

Room is a Database Object Mapping library that makes it easy to access database on Android applications. Rather than hiding the details of SQLite, Room tries to embrace them by providing convenient APIs to query the database and also verify such queries at compile time.


1 Answers

Here you have an example.

https://github.com/jsperk/PocRoom

Remember, you need add:

Gradle (Project)--> maven

Gradle (Module App) dependencies -->

implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
testImplementation "android.arch.persistence.room:testing:1.0.0"
implementation "android.arch.persistence.room:rxjava2:1.0.0"
like image 96
Jsperk Avatar answered Nov 05 '22 04:11

Jsperk