Firebase Android - Crash With "found A Conflicting Setters With Name: Setgregorianchange" When .setvalue()
Solution 1:
I found the answer (with your help Deepesh).
The class I want to save in FirebaseDatabase contains these variables :
publiclong startTime;
publiclong endTime;
And the app crash when I have this method (probably because Firebase think that they are getters) :
public Calendar getStartTimeCalendar() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(startTime);
return calendar;
}
public Calendar getEndTimeCalendar() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(endTime);
return calendar;
}
The solution is to prefix those methods by @Exclude
Solution 2:
The Firebase Database is a JSON database, which means that it natively can only store JSON types. If you're trying to store any other type of information, it will have to converted between that type and an underlying JSON type, a process known as serializing/deserializing the data.
The Java-to-JSON serialization/deserialization that is built into the Firebase Database SDK for Android can serialize/deserialize all supported JSON types and can handle simple Java objects that consist of these types. It cannot (and isn't meant to) deal with most pre-existing classes in the Android or Java SDK, such as java.util.GregorianCalendar
.
If you want to store a date in the Firebase Database, you'll have to come up with your own way of storing them. For dates this typically comes down to one of these ways:
- store the date as a UNIX timestamp (milliseconds since the epoch)
- store the date as separate year, month and day properties
- store the date as a string
How to implement these, depends a bit on how you got the GregorianCalendar
in the first place.
Solution 3:
IgnoreExtraProperties annotation doesn't work even if you have no field that get could correspond with
Post a Comment for "Firebase Android - Crash With "found A Conflicting Setters With Name: Setgregorianchange" When .setvalue()"