Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Firebase Firestore分布式计数器-未找到要序列化的属性_Java_Android_Firebase_Google Cloud Firestore_Counter - Fatal编程技术网

Java Firebase Firestore分布式计数器-未找到要序列化的属性

Java Firebase Firestore分布式计数器-未找到要序列化的属性,java,android,firebase,google-cloud-firestore,counter,Java,Android,Firebase,Google Cloud Firestore,Counter,我已经阅读并根据本文的建议修改了代码 但是,我的问题仍然存在,出现了相同的错误: java.lang.RuntimeException: No properties to serialize found on class com.blush.android.blush.chat.chatCloudCommunications.ChatCloudSentMessageToFirestore$Counter 我在一个名为ChatCloudSentMessageToFirestore的公共类中运行下

我已经阅读并根据本文的建议修改了代码

但是,我的问题仍然存在,出现了相同的错误:

java.lang.RuntimeException: No properties to serialize found on class com.blush.android.blush.chat.chatCloudCommunications.ChatCloudSentMessageToFirestore$Counter
我在一个名为ChatCloudSentMessageToFirestore的公共类中运行下面的所有内容。我省略了在同一个类中定义的“createCounter”、“getCounter”和“incrementCounter”。我这样做是为了保持代码简短,因为它们与Firebase Firestore网站上定义的内容相同:因此不太可能是错误的原因(除非它们需要我不知道的任何修改)

我在同一类中也有此引用:

DocumentReference counterChrisDocRef = db.collection("users")
        .document("ypiXrobQxuZ0wplN5KO8gJf934")
        .collection("conversations")
        .document("conversation0") //Specified conversation
        .collection("messageCounter")
        .document("shards");
我正在尝试使用此方法中的计数器:

public void addSentMessageToFirestoreDB(final Map<String, Object> messageSent) {
    WriteBatch batch = db.batch();

    createCounter(counterChrisDocRef, 1);

    incrementCounter(counterChrisDocRef, 1);


    DocumentReference chrisSentMessageRef = db.collection("users")
            .document("ypiXrobQxuZ0wplN5KO8gJf934")
            .collection("conversations")
            .document("conversation0") //Specified conversation
            .collection("messages")
            .document("message" +  getCount(counterChrisDocRef) + " (sent)");

    batch.set(chrisSentMessageRef, messageSent);

    batch.commit().addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

        }
    });
public void addSentMessageToFirestoreDB(最终映射消息已发送){
WriteBatch batch=db.batch();
createCounter(counterChrisDocRef,1);
递增计数器(计数器chrisdocref,1);
DocumentReference chrisSentMessageRef=db.collection(“用户”)
.文件(“ypiXrobQxuZ0wplN5KO8gJf934”)
.收集(“对话”)
.document(“conversation0”)//指定的对话
.收集(“信息”)
.document(“message”+getCount(counterChrisDocRef)+(sent)”;
batch.set(chrissentmesseref,messageSent);
batch.commit().addOnCompleteListener(新的OnCompleteListener()){
@凌驾
未完成的公共void(@NonNull任务){
}
});

由于您的类中的字段根本没有使用公共getter,请将所有字段
设置为公共的,因为在您的代码中现在是默认的。为了直接在字段上设置值,您的字段必须是
公共的
。如果您想让字段私有,只需将相应的公共getter添加到一切都会好起来的


还请从您的
Shard
类中删除
static
关键字。无需使该类
static

,因为您的类中的字段根本没有使用公共getter,请使所有字段
公共
,因为在您的代码中现在是默认值。为了直接设置值在您的字段上,您的字段必须是
公共的
。如果您想让您的字段成为私有的,只需添加相应的公共getter,一切都会正常工作

还请从
Shard
类中删除
static
关键字。无需将该类设置为
static

public void addSentMessageToFirestoreDB(final Map<String, Object> messageSent) {
    WriteBatch batch = db.batch();

    createCounter(counterChrisDocRef, 1);

    incrementCounter(counterChrisDocRef, 1);


    DocumentReference chrisSentMessageRef = db.collection("users")
            .document("ypiXrobQxuZ0wplN5KO8gJf934")
            .collection("conversations")
            .document("conversation0") //Specified conversation
            .collection("messages")
            .document("message" +  getCount(counterChrisDocRef) + " (sent)");

    batch.set(chrisSentMessageRef, messageSent);

    batch.commit().addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

        }
    });