Receiving object from Firebase isn´t working
<p>I´m trying to receive an costum object from my Firebase database.
I allways get an exception and I can´t figure out why...</p>

<blockquote>
  <p>------- beginning of crash 06-17 08:26:56.208 13875-13875/com.example.jendrik.moerder E/AndroidRuntime: FATAL
  EXCEPTION: main<br>
  Process: com.example.jendrik.moerder, PID: 13875<br>
  com.google.firebase.database.DatabaseException: Can't convert object
  of type java.util.ArrayList to type
  com.example.jendrik.moerder.GameObjekts.Clue<br>
  at com.google.android.gms.internal.zzaix.zzd(Unknown Source)<br>
  ...a lot of double errors...<br>
  at com.google.firebase.database.DataSnapshot.getValue(Unknown Source) 
  at
  com.example.jendrik.moerder.FCM.FCMListeners.updateGame(FCMListeners.java:64)
  at
  com.example.jendrik.moerder.FCM.FCMListeners.access$000(FCMListeners.java:26)
  at
  com.example.jendrik.moerder.FCM.FCMListeners$1.onDataChange(FCMListeners.java:105)
  at com.google.firebase.database.Query$1.onDataChange(Unknown Source)<br>
  at com.google.android.gms.internal.zzafp.zza(Unknown Source)<br>
  at com.google.android.gms.internal.zzagp.zzSu(Unknown Source)<br>
  at com.google.android.gms.internal.zzags$1.run(Unknown Source)<br>
  at android.os.Handler.handleCallback(Handler.java:739)<br>
  at android.os.Handler.dispatchMessage(Handler.java:95)<br>
  at android.os.Looper.loop(Looper.java:224)<br>
  at android.app.ActivityThread.main(ActivityThread.java:5526)<br>
  at java.lang.reflect.Method.invoke(Native Method)<br>
  at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)</p>
</blockquote>

<p>This is how I load the object into DB:</p>

<pre><code>public void sendGame(Game game){
    DatabaseReference myRef = FirebaseDatabase.getInstance().getReference();
    myRef.child("games").child(gameName).setValue(game);
}
</code></pre>

<p>This is the way how I receive it:</p>

<pre><code> public FCMListeners(String gameName, GameStartedCallback callback){

    this.gameName=gameName;
    this.callback = callback;
    gameReference = FirebaseDatabase.getInstance().getReference().child("games").child(gameName);
    gameListener = makeGameListener();
    gameReference.addListenerForSingleValueEvent(gameListener);
}



public ValueEventListener makeGameListener(){

    ValueEventListener ve =
            new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    updateGame(dataSnapshot);
                    callback.startGameAfterReceivingInformation();
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            };

    return ve;
}

private void updateGame(DataSnapshot snapshot){
    Log.d("tollewurst",snapshot.getKey());
    Game game=snapshot.getValue(Game.class);
    this.game=game;
}

public Game getGame(){
    return game;
}
</code></pre>

<p>From the running class I call FCMListener for receiving:</p>

<pre><code> private FCMListeners fcmListeners;

private void startGame(){
    myRef.removeEventListener(el);
    gamestarter.removeEventListener(elGame); //these are listeners for other informations who are not used anymore at this point

    fcmListeners = new FCMListeners(gameName, this);
}

public void startGameAfterReceivingInformation(){
    Intent intent = new Intent(this,MenueDrawer.class);
    intent.putExtra("gameName", gameName);
    intent.putExtra("whoAmI", checkForPlayerNumber());

    Game game = fcmListeners.getGame();
    intent.putExtra("GAME", game);
    Log.d("start",game.getGameName());

    startActivity(intent);
}
</code></pre>

<p>My interfacec for the callback:</p>

<pre><code>public interface GameStartedCallback {
void startGameAfterReceivingInformation();
}
</code></pre>

<p>Here is my Game.class - the class of the to receiving object:</p>

<pre><code>@Getter @Setter
@IgnoreExtraProperties
public class Game implements Serializable {

private Solution solution;
private RoomManager roomManager;
private WeaponManager weaponManager;
private PlayerManager playerManager;
private List&lt;Clue&gt; clueList;
private double numberOfThings;
private String gameName;
private String pwd;
private double min;
private double sec;
private double justScannedQR;
private double playerAmount;
private boolean gameOver;
private boolean isRunning;

public Game(String gameName, String pwd, ArrayList&lt;String&gt; rooms, ArrayList&lt;String&gt; weapons, int min, int sec, int playerAmount){
    this.gameName = gameName;
    this.pwd = pwd;
    this.min = min;
    this.sec = sec;
    solution = null;
    clueList = new ArrayList&lt;&gt;();
    playerManager = new PlayerManager(false);
    weaponManager = new WeaponManager(false);
    roomManager = new RoomManager(false);
    createRooms(rooms);
    createWeapons(weapons);
    numberOfThings = rooms.size() + weapons.size();
    justScannedQR = 0;
    this.playerAmount = playerAmount;
    gameOver = false;
}

public Game(){} //and then a lot of methods who are @Exclude
</code></pre>

<p>What I allready tried was switching the child-nodes in different ways, because of the "unknown path" part in the error-dialog. Unsurprisely without any luck.</p>

<p>Strange thing is, on other points I don´t have problems with lists and single values (most boolean at the moment). I guess there is something wrong with my Game.class</p>

<p>Would be great if anybody can help me.
I hope these are enough informations. </p>

<p>I´ve found the solution after days...
While cleaning up the code I´ve found a snippet in a different class:</p>

<pre><code>public void setGivenClues(Clue clue){ givenClues.add(clue); }
</code></pre>

<p>Because of this setter the app crashed. Inside my Player-object (part of the game object) is a Clue-list. This setter should add single clues in a list. But Firebase interpreted it as a setter for a whole list. After renaming my setter and changing the calling code everything was fine!</p>