Reputation: 965
I don't know why I'm having this warning:
W/Firestore: (21.3.1) [CustomClassMapper]: No setter/field for
lh
. found on class 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
.
As you can see in the code, first I read this document:
(B): calSnapshot
.
And then, in the second instance, I read another document that is referred in one field of type document
in (A):
And I map this second document to the Liturgia.class
.
If I try to name the method as set lh()
or I try without @PropertyName("lh")
the warning shows always.
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.
Upvotes: 1
Views: 1883
Reputation: 138924
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:
Here are the steps for solving the entire problem:
lh
property to be of type HashMap<String, Object>
HashMap<String, Object>
HashMap<String, Object>
into the setter.So, here si the getter:
public HashMap<String, Object> getLh() {
return lh;
}
And for the setter:
public void setLh(HashMap<String, Object> lh) {
this.lh = lh;
}
Upvotes: 4