4

I am getting this error:

Caused by: com.google.firebase.database.DatabaseException: Found conflicting getters for name: isAccessibilityFocusable

while trying to update my User.

The User class is like this

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;
}
}

I am trying to update the User like this

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);

The setTurnInFirebase method is like this

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

So when I run the project, I get the above mentioned error. What could be the reason for this. Thankyou

AL.
  • 36,815
  • 10
  • 142
  • 281
theanilpaudel
  • 3,348
  • 8
  • 39
  • 67
  • I think this post have answer for your problem: [http://stackoverflow.com/a/37802772...](http://stackoverflow.com/a/37802772/4112725) – koceeng Feb 23 '17 at 09:55

1 Answers1

7

Your user contains a TextView, which is a class that Firebase won't be able to serialize/deserialize.

To allow writing a class to the Firebase Database, make sure that it only contains properties of simple types or objects that you created: so called POJOs - Plain Old Java Objects.

Alternatively you can exclude the non-supported properties (such as the TextView) by annotating them:

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

@Exclude
public void setTextView(TextView textView) {
    this.textView = textView;
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Frank: Note that the user has @Exclude on the `textView` field declaration. As your answer correctly indicates, the @Exclude must be on the getter/setter. The documentation for @Exclude needs some attention. The [Upgrade Guide](https://firebase.google.com/support/guides/firebase-android#update_your_java_model_objects_numbered) contains an example with @Exclude on the field declaration. The [documentation for @Exclude](https://developers.google.com/android/reference/com/google/firebase/database/Exclude) states _Marks a field as excluded from the Database_, which is ambiguous. – Bob Snyder Feb 23 '17 at 16:32
  • Ah, good point! I had overlooked it on the field. It must indeed be on both getter and setter. There's an open task for requiring it only in one place, but it's been tricky to decide where. – Frank van Puffelen Feb 23 '17 at 19:22