Firebase数据库错误:找到名称冲突的getter:isAccessibilityFocusable

时间:2017-02-23 08:07:00

标签: android firebase firebase-realtime-database

我收到此错误:

  

引起:com.google.firebase.database.DatabaseException:找到名称冲突的getter:isAccessibilityFocusable

尝试更新我的用户时。

User类就像这样

public class User {
@PrimaryKey
String userName;
String groupName;
int totalMoney;
boolean turn;
boolean hapyo;
boolean blind;
@Exclude
TextView textView;
@Exclude
Button bHapdiye,bChale,bShow,bHeram;

public Button getbHapdiye() {
    return bHapdiye;
}

public void setbHapdiye(Button bHapdiye) {
    this.bHapdiye = bHapdiye;
}

public Button getbChale() {
    return bChale;
}

public void setbChale(Button bChale) {
    this.bChale = bChale;
}

public Button getbShow() {
    return bShow;
}

public void setbShow(Button bShow) {
    this.bShow = bShow;
}

public Button getbHeram() {
    return bHeram;
}

public void setbHeram(Button bHeram) {
    this.bHeram = bHeram;
}

public TextView getTextView() {
    return textView;
}

public void setTextView(TextView textView) {
    this.textView = textView;
}

public boolean isBlind() {
    return blind;
}

public void setBlind(boolean blind) {
    this.blind = blind;
}


public boolean isHapyo() {
    return hapyo;
}

public void setHapyo(boolean hapyo) {
    this.hapyo = hapyo;
}

public boolean isTurn() {
    return turn;
}

public void setTurn(boolean turn) {
    this.turn = turn;

}

public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

public String getGroupName() {
    return groupName;
}

public void setGroupName(String groupName) {
    this.groupName = groupName;
}

public int getTotalMoney() {
    return totalMoney;
}

public void setTotalMoney(int totalMoney) {
    this.totalMoney = totalMoney;
}
}

我正在尝试像这样更新用户

final User user1 = userList.get(0);
    user1.setTextView(tvUser1);
    user1.setbChale(bChaleP1);
    user1.setbHapdiye(bHapdiyeP1);
    user1.setbHeram(bHeramP1);
    user1.setbShow(bShowP1);
    user1.setTurn(true);
    setUsersTurn(user1.isTurn(),bHapdiyeP1,bChaleP1,bShowP1,bHeramP1);
    setTurnInFirebase(user1);

setTurnInFirebase方法就像这样

public void setTurnInFirebase(User user){
    myRef.child("users").setValue(user);
}

所以当我运行项目时,我得到了上面提到的错误。这可能是什么原因。三江源

1 个答案:

答案 0 :(得分:7)

您的用户包含TextView,这是Firebase无法序列化/反序列化的类。

要允许将类编写到Firebase数据库,请确保它只包含您创建的简单类型或对象的属性:所谓的POJO - 普通旧Java对象。

或者,您可以通过注释来排除不受支持的属性(例如TextView):

@Exclude
public TextView getTextView() {
    return textView;
}

@Exclude
public void setTextView(TextView textView) {
    this.textView = textView;
}