android - 无法解析 Firestore 中的方法增量(错误:找不到符号方法增量(int))
问题描述
我无法让这段代码工作:
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.model.value.FieldValue;
private FirebaseFirestore db;
public void onCreate(){
...
db = FirebaseFirestore.getInstance();
...
}
private void increment() {
DocumentReference washingtonRef = db.collection("cities").document("DC");
// Atomically increment the population of the city by 50.
washingtonRef.update("population", FieldValue.increment(50));
}
我尝试同时使用:
com.google.firebase.firestore
com.google.firebase.firestore.model.value
但它仍然不起作用
当我尝试构建它时,出现错误:
找不到符号方法增量(int)
解决方案
正确的类是com.google.firebase.firestore.FieldValue
.
如果使用该路径未向您显示increment
方法,则您很可能使用的 SDK 版本尚不包含该方法。检查您的 gradle 文件,然后升级到最新版本。
推荐阅读
- wmi - CCM_Application 用户可用软件缺失
- html - Angular 2 CLI 项目中的 Bootstrap 4 按钮间距
- java - 具有多种实现的 Java 通用接口
- java - 熟悉异常处理
- javascript - 如何格式化接收到的 JSON 使其看起来很漂亮?
- firebase - 网页通知,在桌面同时接收所有通知
- android - 从外部浏览器(已安装的浏览器应用程序)或系统 webview 获取 Cookie 并分配给 webview
- javascript - 承诺给 then() 一个函数参数
- c# - 如何在 C# 帮助中解决这个 x^2+13^x=z^2
- java - Spring @Repository 异常翻译