【发布时间】:2019-10-31 16:48:03
【问题描述】:
我目前正在使用带注释的 POJO 将 Firestore 文档集成到 Kotlin 应用程序中以提取数据。作为其中的一部分,我还需要文档的 ID。
我正在尝试使用 here 描述的新 @DocumentId 表示法来做到这一点...
但是在我的 POJO 类中无法识别注释(未解析的引用:DocumentId)
在我的 gradle 文件中,我有...
implementation 'com.google.firebase:firebase-firestore:21.2.1'
在我的模型课中,我有...
data class DocumentModel(
@DocumentId var id: String
@PropertyName var field1: String
...etc...
)
其他注释工作正常,只是 DocumentId 一个不起作用。有人对我做错了什么有任何想法吗?
【问题讨论】:
-
你导入了吗?
-
当我使用
import com.google.firebase.firestore.DocumentId时尝试显示“未解析的引用” -
我没有问题。确保您已将 gradle 与您的项目同步。
-
同步但没有变化。无效的缓存,重新启动,同步并且现在可以正常工作。谢谢@DougStevenson
标签: android firebase kotlin google-cloud-firestore