1

I'm trying to do a simple Chat project with Firebase but in the method to singing I have an error of FirebaseException: Failed to bounce to type when I try to instantiate the currentUser with dataSnapshot. This is the method:

public void signIn(String email, String password) {
    dataReference.authWithPassword(email, password, new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            myUserReference = helper.getMyUserReference();
            myUserReference.addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    User currentUser = dataSnapshot.getValue(User.class);
                    if (currentUser == null) {
                        String email = helper.getAuthUserEmail();
                        if (email != null) {
                            currentUser = new User();
                            myUserReference.setValue(currentUser);
                        }
                    }
                    helper.changeUserContectionStatus(User.ONLINE);
                    postEvent(LoginEvent.ON_SING_IN_SUCCESS);
                }

                @Override
                public void onCancelled(FirebaseError firebaseError) {

                }
            });
        }

        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            postEvent(LoginEvent.ON_SING_IN_ERROR,firebaseError.getMessage() );
        }
    });
}

And this is the POJO:

public class User {
String email;
boolean online;
Map<String,Boolean> contacs;
public static final boolean ONLINE = true;
public static final boolean OFFLINE = false;

public User() {
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public boolean isOnline() {
    return online;
}

public void setOnline(boolean online) {
    this.online = online;
}

public Map<String, Boolean> getContacs() {
    return contacs;
}

public void setContacs(Map<String, Boolean> contacs) {
    this.contacs = contacs;
}

@Override
public boolean equals(Object object){
    boolean equals = false;
    if (object instanceof User) {
        User user = (User)object;
        equals = this.email.equals(user.getEmail());
    }
    return equals;
}
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Williams
  • 19
  • 6
  • There is typically a good error message in that stack trace for these errors. See http://stackoverflow.com/questions/32108969/why-do-i-get-failed-to-bounce-to-type-when-i-turn-json-from-firebase-into-java – Frank van Puffelen Jun 30 '16 at 19:03
  • 1
    Try to comment out ONLINE and OFFLINE variables and check again, i think they might arise the problem – Ami Hollander Jun 30 '16 at 19:08

0 Answers0