问题描述
我在我的应用中使用 Android Room Persistence 库 (v.1.0.0-alpha1).虽然它工作正常,但当我在 Android Studio 中打开模型类(Kotlin 数据类)时,它显示了用于 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 数据库 - 未解析的引用 @Entity 和其他注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!