9

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"
silwar
  • 6,470
  • 3
  • 46
  • 66
  • Can you paste all the Persistence Library related imports from your build.gradle? Did you add the import for annotation processor? – lidkxx Aug 17 '17 at 12:56
  • Have you tried clean/rebuild? Do you have Maven added in build.gradle?Documentation: https://developer.android.com/topic/libraries/architecture/adding-components.html Also, in this project you can check the correct setup for Room https://github.com/riggaroo/android-arch-components-date-countdown/blob/master/app/build.gradle Check out this question also: https://stackoverflow.com/questions/44142964/room-persistence-lib-implementation-in-kotlin – lidkxx Aug 18 '17 at 07:57
  • Could you pour in some additional code ? Like an entity and related DAO and DB. – Oyzuu Aug 18 '17 at 08:05
  • @lidkxx I am not sure whether this is correct implementation or not but after i put compile "android.arch.persistence.room:common:1.0.0-alpha5" in build.gradle above problem got solved – silwar Aug 18 '17 at 12:42

3 Answers3

6

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"
Lal Krishna
  • 15,485
  • 6
  • 64
  • 84
Jsperk
  • 124
  • 1
  • 11
4

In my project, I have this question cause I'm using

android.arch.lifecycle:livedata:1.1.1

than no matter using room with version 1.1.1 or 1.0.0, it still can't find the android.arch.persistence.room.Entity.

I've searched for a long time, till I found that, when I delete the LiveData implementation, the problem solved. Then I notice that, the version of these two libraries conflict. At last, I use the same version of 1.1.0 for livedata and room (since livedata have no version of 1.0.0), and solved it.

def arch_version = "1.1.0"
implementation  "android.arch.persistence.room:runtime:$arch_version"
annotationProcessor "android.arch.persistence.room:compiler:$arch_version"
implementation "android.arch.persistence.room:rxjava2:$arch_version"
implementation "android.arch.persistence.room:common:$arch_version"
implementation "android.arch.lifecycle:livedata:$arch_version"
implementation "android.arch.lifecycle:extensions:$arch_version"
Lam
  • 179
  • 1
  • 3
0

Adding these dependencies to your Gradle(Module App) file will solve it:-

implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
testImplementation "android.arch.persistence.room:testing:1.1.1"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
Mukul Raghav
  • 349
  • 2
  • 5