Firebase No Properties to Serialize Found on Class

Firebase No properties to serialize found on class

Firebase require your Pojo to have public variables or getter/setter.

Change variable declarations to public

public String nombre;
public String apellidos;
public String telefono;
public String email;
public Boolean tieneWhatsapp;
public Boolean tieneTelegram;
public Boolean tieneHangouts;
public Long formaPago;
public Double ratioHora;
public Double precioHora;
public Double horasCompensadas;

Firebase - No properties to serialize found on class

To solve this, your class needs to implement the Serializable interface:

class dataModel implements Serializable {}

You also need to add a contructor with three arguments. Your class should look like this:

class dataModel implements Serializable {
private String id, name;
private Integer count;
@ServerTimestamp
private Date time;

dataModel() {}

dataModel(String id, String name, Integer count) {
this.id = id;
this.name = name;
this.count = count;
}
}

If the date is null, it will have the server-generated timestamp. So you don't need to do set the value for it. Please also see the annotation used to mark a Date field to be populated with a server timestamp.

Also very important, don't forget to add public getters.

and the other requirement will be to add -keepclassmembers class com.yourcompany.models.** { *; } in proguard-rules.pro.

As said here.

DatabaseException: No properties to serialize found on class

Check your detailsOfUser class, it should implement Serializable and have an empty constructor.
When you use FirebaseDatabase the classes you use to represent stored data must be Serializable, this way the object can be turned into a JSON string and vice versa.

Firestore No properties to serialize found on in kotlin

Issue was since some of the variables of the kotlin data class initialized as null but without any specific data type. I just added the data types and issue solved

data class Glist  (
var id: String,
val ti: String,
val cat: Int
) {

constructor() : this("", "", 0)

var lactuid = Fire.getUid()
var lact = ActionHelper.CREATED_LIST
var lacti = ""
var arch: Date? = null
var del: Date? = null
var lactd: Date
var cre: Date
var cha: Date
var own = Fire.getUid()
var adminuid: ArrayList<String>? = null
var col = ArrayList<String>( )
var ni = ArrayList<String>( )
var nci = ArrayList<String>( )

init {
val now: Date = TimeUtil.getTime()
lactd = now
cre = now
cha = now
col.add(Fire.getUid())
}
}

Firestore : No properties to serialize found on class

The above error was resolved after doing the following:

  1. Clean and rebuild project.
  2. Removing all proguard rules.
  3. Adding @Keep in each model class beginning.


Related Topics



Leave a reply



Submit