I've been working on an android app for attendance with localization. The database is connected to firebase to track users in realtime. While implementing the registration form I've been through this Error and I could never get out of it. Whenever I try to register as a student or a teacher the application crashes . I referenced that very close but it didn't help me also. here is my code
package com.example.appla.iattended;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.firebase.client.Firebase;
public class SignUpActivity extends AppCompatActivity {
EditText email, password,id, confirmPassword;
String str_email, str_password,str_id, str_confirmPassword;
Boolean email_verified, password_verified, isTA, id_verified;
Firebase ref = new Firebase("https://yattend-755ad.firebaseio.com/");
Button signUp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
Firebase.setAndroidContext(this);
email = (EditText) findViewById(R.id.txt_signup_email);
password = (EditText) findViewById(R.id.txt_signup_password);
confirmPassword = (EditText) findViewById(R.id.txt_signup_confirm_password);
id = (EditText) findViewById(R.id.txt_signup_id);
email.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
email.setHint("");
else
email.setHint("GUC email");
}
});
password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
password.setHint("");
else
password.setHint("Password");
}
});
confirmPassword.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
confirmPassword.setHint("");
else
confirmPassword.setHint("Confirm Password");
}
});
id.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
id.setHint("");
else
id.setHint("XX-XXXXX");
}
});
signUp = (Button) findViewById(R.id.btn_login);
signUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//generate strings
str_email = email.getText().toString();
str_password = password.getText().toString();
str_confirmPassword = confirmPassword.getText().toString();
str_id = id.getText().toString();
//checking password
if(str_password.equals(str_confirmPassword)){
password_verified = true;
}else{
password_verified = false;
Toast.makeText(SignUpActivity.this,
"Passwords do not match, please try again.", Toast.LENGTH_LONG).show();
}
//checking email
if(str_email.endsWith("@student.guc.edu.eg")){
email_verified = true;
isTA =false;
}else if(str_email.endsWith("@guc.edu.eg")) {
email_verified = true;
isTA=true;
}else{
email_verified = false;
Toast.makeText(SignUpActivity.this,
"Incorrect Email. Please use your GUC email.", Toast.LENGTH_LONG).show();
}
//checking id
if(str_id.contains("-") && str_id.length() > 4){
id_verified =true;
}else if (str_id.equals("") && isTA) {
id_verified = true;
} else{
id_verified =false;
Toast.makeText(SignUpActivity.this,
"Please insert GUC ID or if TA, leave blank.", Toast.LENGTH_LONG).show();
}
//To firebase
if(email_verified && password_verified && id_verified){
//Insert
User user = new User(str_email,str_password,str_id,isTA);
Firebase newRef = ref.child("Users").push();
newRef.setValue(user);
if(isTA){
//Redirect to TA's page
Intent myIntent = new Intent(SignUpActivity.this, StartSessionActivity.class);
SignUpActivity.this.startActivity(myIntent);
}else{
//Redirect to students page
Intent myIntent = new Intent(SignUpActivity.this, StudentActivity.class);
SignUpActivity.this.startActivity(myIntent);
}
}
}
});
}
}
here is User class:
package com.example.appla.iattended;
public class User {
String email, password,id;
Boolean isTa;
public User(String email, String password, String id,Boolean isTa){
this.email=email;
this.password=password;
this.id=id;
this.isTa=isTa;
}
}
and here is my generated Log whenever I press the button register
FATAL EXCEPTION: main
com.firebase.client.FirebaseException: Failed to parse to snapshot
at com.firebase.client.Firebase.setValueInternal(Firebase.java:347)
at com.firebase.client.Firebase.setValue(Firebase.java:238)
at com.example.appla.iattended.SignUpActivity$5.onClick(SignUpActivity.java:122)
at android.view.View.performClick(View.java:4211)
at android.view.View$PerformClick.run(View.java:17267)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: No serializer found for class com.example.appla.iattended.User and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2615)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542)
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336)
at com.firebase.client.Firebase.setValue(Firebase.java:238)
at com.example.appla.iattended.SignUpActivity$5.onClick(SignUpActivity.java:122)
at android.view.View.performClick(View.java:4211)
at android.view.View$PerformClick.run(View.java:17267)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class com.example.appla.iattended.User and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:118)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542)
at com.firebase.client.Firebase.setValueInternal(Firebase.java:336)
at com.firebase.client.Firebase.setValue(Firebase.java:238)
at com.example.appla.iattended.SignUpActivity$5.onClick(SignUpActivity.java:122)
at android.view.View.performClick(View.java:4211)
at android.view.View$PerformClick.run(View.java:17267)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)