Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Android - Crash with "Found a conflicting setters with name: setGregorianChange" when .setValue()

I'm playing with FirebaseDatabase and I can't resolve a very annoying crash.

Everytime I try to execute: FirebaseDatabase.getInstance().getReference().child("...").push().setValue(...)

The app crash and I have this message :

com.google.firebase.database.DatabaseException: Found a conflicting setters with name: setGregorianChange (conflicts with setGregorianChange defined on java.util.GregorianCalendar)
at com.google.android.gms.internal.zzbqi$zza.<init>(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzi(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaE(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaw(Unknown Source)
at com.google.firebase.database.DatabaseReference.zza(Unknown Source)
at com.google.firebase.database.DatabaseReference.setValue(Unknown Source)

This crash start happening after I tried to save an Object which contained a Calendar in FirebaseDatabase.

The problem is that, now, even if I remove the Calendar from this Object, the app keep crashing with the same error. It looks like something has been corrupted and I can't make it works again.

I have uninstall the app from my phone, clear the Database in Firebase Console but that didn't fix the problem.

Does one of you can help me?

----- EDIT -----

I did some new tests and actually the app keep crashing only if the class that I pass in .setValue(...) contains this method :

public Calendar getStartTimeCalendar() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(startTime);
    return calendar;
}
like image 445
Valentin Avatar asked Mar 10 '23 00:03

Valentin


1 Answers

I found the answer (with your help Deepesh).

The class I want to save in FirebaseDatabase contains these variables :

public long startTime;
public long 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

like image 88
Valentin Avatar answered Apr 25 '23 12:04

Valentin