Java 无法在Firestore数据库中归档记录
我正在尝试创建一个新文档,它在logcat中没有给我错误,但它甚至没有创建它 我检查了地址并检索了所需的值,它们都是正确的 请让我知道我在下面的代码中哪里错了Java 无法在Firestore数据库中归档记录,java,android,firebase,google-cloud-firestore,Java,Android,Firebase,Google Cloud Firestore,我正在尝试创建一个新文档,它在logcat中没有给我错误,但它甚至没有创建它 我检查了地址并检索了所需的值,它们都是正确的 请让我知道我在下面的代码中哪里错了 db.collection("posts").document(postId).collection("comments").document(commentId).collection("messageRoom").document(roomId).collection("messages") .add(
db.collection("posts").document(postId).collection("comments").document(commentId).collection("messageRoom").document(roomId).collection("messages")
.add(chat)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
successCallback.onSuccess(documentReference);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
failureCallback.onFailure(e);
}
});
db.collection(“posts”).document(postId).collection(“comments”).document(commentId).collection(“messageRoom”).document(roomId).collection(“messages”)
.添加(聊天)
.addOnSuccessListener(新的OnSuccessListener(){
@凌驾
成功时公共无效(文档引用文档引用){
successCallback.onSuccess(documentReference);
}
})
.addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
失败回调。失败时(e);
}
});
请让我看看您的(聊天)地图,并添加Log.d(“TAG”,e.message);进入onFailure()方法。。然后检查Logcat以了解运行代码时会发生什么情况您是否尝试从引用中硬编码所有这些变量(postId、commentId和roomId)?这样行吗?也请用@ AlxMaMeBTW回答,如果你考虑在某个时间点尝试另一种方法来聊天应用,这里你可以找到一个教程,说明如何创建一个完整的和功能性的。@ AlxMaMo感谢教程参考,但是我正在使用java,而且现在没有任何基本的KoTLIN,但我保存了参考资料以备将来使用。