DatabaseException: Found two getters or fields with conflicting case sensitivity

左心房为你撑大大i 提交于 2019-11-27 23:12:00

The Firebase Database consider these items when serializing/deserializing JSON:

  • public fields
  • JavaBean-like property getters/setters

Since you have both a public field N and getN()/setN() methods, it considers the two in conflict. While in this case setting N and calling setN() leads to the same result, that may not always be the case. The chance of getting it wrong is too big, which is why the scenario is simply not allowed.

The error message is a bit of a red herring in this case. We should improve that.

Convert the following fields from public to private

public int K;
public double L;
public int D;
public int N;

to

private int K;
private double L;
private int D;
private int N;

I found a different solution to keep my field public String id and at the same time have the method public String getId() which I needed to implement because of an interface: Simply mark the method with @Exclude, e.g.:

public class Group implements Identifiable<String>
{
    public String id;

    protected Group ()
    {
    }

    public Group ( String id )
    {
        this.id = id;
    }

    @Exclude
    @Override
    public String getId ()
    {
        return id;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!