2017-02-23 46 views
0

我收到此錯誤:火力地堡數據庫錯誤:矛盾的發現爲干將名稱:isAccessibilityFocusable

Caused by: com.google.firebase.database.DatabaseException: Found conflicting getters for name: 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); 
} 

所以,當我運行用戶該項目,我得到了上述錯誤。這可能是什麼原因。 Thankyou

+0

我覺得這個職位有回答您的問題:http://stackoverflow.com/a/ 37802772 ...](http://stackoverflow.com/a/37802772/4112725) – koceeng

回答

3

您的用戶包含TextView,這是Firebase無法序列化/反序列化的類。

要允許將類寫入Firebase數據庫,請確保它只包含您創建的簡單類型或對象的屬性:所謂的POJO - 普通舊Java對象。

或者,你可以註解它們排除不支持的特性(如TextView):

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

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

Frank:請注意,用戶在'textView'字段聲明中具有@Exclude。正如你的答案正確表明,@Exclude必須在getter/setter上。 @Exclude文檔需要注意。 [升級指南](https://firebase.google.com/support/guides/firebase-android#update_your_java_model_objects_numbered)在字段聲明中包含一個帶有@Exclude的示例。 [[@Exclude的文檔]](https://developers.google.com/android/reference/com/google/firebase/database/Exclude)聲明_將一個字段標記爲從Database_中排除,這是不明確的。 –

+0

啊,好點!我在球場上忽視了它。它必須在吸氣和吸氣兩方面。只有在一個地方纔需要它,這是一個開放的任務,但決定在哪裏卻很棘手。 –