问题描述
我在我的应用中使用Android Room Persistence库(v.1.0.0-alpha1).尽管运行良好,但是当我在Android Studio中打开模型类(Kotlin Data类)时,它会显示用于Room数据库的所有注释(例如 @Entity , @ColumnInfo 等.我尝试将Arch库的版本更改为1.0.0-alpha5,但结果相同.
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.
在Lint检查中,所有导入的注释均显示删除不赞成使用的符号导入.AS之前未显示此错误.
In Lint inspection it is showing Remove deprecated symbol import for all imported annotations.AS was not showing this error previously.
我该如何解决此问题
修改以下是我在build.gradle中添加的导入
EditFollowing 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"
推荐答案
这里有个例子.
https://github.com/jsperk/PocRoom
请记住,您需要添加:
Gradle(项目)-> maven
Gradle (Project)--> maven
Gradle(模块应用程序)依赖性->
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"
这篇关于Android Room Database-未解决的参考@Entity和其他注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!