[CustomClassMapper] : 대한 없음 세터 / 필드 없다 ... 중포 기지 경우 FireStore의 클래스에 발견

A. Cedano :

나는이 경고를 보내고 있습니다 이유를 알고하지 않습니다

W / 경우 FireStore (21.3.1) CustomClassMapper] : 없음 세터 / 필드 lh. 클래스 com.example.model.Liturgia에서 발견

데이터를 가져 오는 코드 :

    DocumentReference calRef = db.collection(CALENDAR_PATH).document(fechaYY).collection(fechaMM).document(fechaDD);
    calRef.addSnapshotListener((calSnapshot, e) -> {
        if ((calSnapshot != null) && calSnapshot.exists()) {
            mLiturgia = calSnapshot.toObject(Liturgia.class);
            DocumentReference dataRef = calSnapshot.getDocumentReference("lh.1");
            // ...

모델

public class Liturgia {
    private Breviario lh;
    //...

    public Liturgia() {
    }

    @Exclude
    public void getlh() {
    }

    @PropertyName("lh")
    public void setLh(Breviario lh) {
        this.lh = lh;
    }
}

서류

(A)calRef .

당신은 코드에서 볼 수 있듯이, 처음 나는이 문서를 읽을 수 :

여기에 이미지 설명을 입력

(B)calSnapshot .

그리고, 두 번째 예에서, I 형은 하나 개의 필드로 지칭되는 다른 문서 판독 document(A)를 :

여기에 이미지 설명을 입력

그리고 나는이 두 번째 문서를 매핑 Liturgia.class.

나는 같은 방법을 이름을하려고하면 set lh()아니면 내가없이하려고 @PropertyName("lh")항상 경고를 보여줍니다.

The code works as expected, but I don't want to see this warning.

I see this answer: W/Firestore: [CustomClassMapper]: No setter/field for class Android but in my case, the name of the property and the name of the method are the same.

Alex Mamo :

You are getting the following warning:

W/Firestore: (21.3.1) [CustomClassMapper]: No setter/field for lh found on class com.example.model.Liturgia

Because the lh property in your Liturgia class is of type Breviario, while in the database is an array of Strings. Both must match. So if you need to keep the current database data, change that property to be of type List<String>.

Besides that, using:

@PropertyName("lh")

It is useless because the property in the database is already called lh. So there is no need for that.

Edit:

여기에 전체 문제를 해결하기위한 단계는 다음과 같습니다

  1. 선언 lh형으로 속성을HashMap<String, Object>
  2. @Ignore 주석을 제거
  3. 을 반환 게터 무효의 반환 유형 변경 HashMap<String, Object>
  4. 을 설정 HashMap<String, Object>세터로.

그래서, 여기에 게터를 SI :

public HashMap<String, Object> getLh() {
    return lh;
}

그리고 세터를위한 :

public void setLh(HashMap<String, Object> lh) {
    this.lh = lh;
}

추천

출처http://10.200.1.11:23101/article/api/json?id=403098&siteId=1