2017-02-23 4 views
0

私はこのエラーを取得しています:Firebaseデータベースエラー:名前のために競合ゲッターが見つかりました:isAccessibilityFocusable

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

私のユーザーを更新しようとしているとき。

Userクラスは、私は、私が実行したときにsetTurnInFirebase方法は、したがって、この

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

のようなものです。この

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

のようなユーザーを更新しようとしています。この

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

のようなものですプロジェクト、私は上記のエラーが発生します。これの理由は何でしょうか。ありがとう

+0

私はこの記事があなたの問題の答えを持っていると思う:[http://stackoverflow.com/a/ 37802772 ...](http://stackoverflow.com/a/37802772/4112725) – koceeng

答えて

3

ユーザにはTextViewが含まれています。これは、Firebaseがシリアル化/逆シリアル化できないクラスです。

クラスをFirebaseデータベースに書き込むことを許可するには、作成した単純なタイプまたはオブジェクトのプロパティ(いわゆるPOJO - Plain Old Java Objects)のみが含まれていることを確認してください。

代わりにあなたがそれらに注釈を付けることで(例えばTextViewなど)サポートされていないプロパティを除外することができます。

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

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

フランク:ユーザーは 'textView'フィールドの宣言で@Excludeを持っていることに注意してください。あなたの答えが正しく示されているので、@ Excludeはゲッター/セッター上になければなりません。 @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)の状態では、_フィールドがデータベースから除外されているとマークしています_はあいまいです。 –

+0

ああ、良い点!私はフィールドでそれを見落としていた。それは確かにゲッターとセッターの両方になければなりません。 1つの場所でしか必要としないオープンな仕事がありますが、どこを決定するのは難しいです。 –

関連する問題