0
I got the mistake and I don’t know what else to do:
Error
01 19:15:53.568 21966 21966 D AndroidRuntime
Shutting down VM 09-01 19:15:53.574 21966 21966 E Androidruntime
FATAL EXCEPTION: main 09-01 19:15:53.574 21966 21966 E
Androhidrountime Process: with.mycompany.parcelsdecartao, PID: 21966 09-01 19:15:53.574 21966 21966 And Androhidrountime
com.firebase.client.Firebaseexception: Failed to Bounce to type 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.firebase.client.DataSnapshot.getValue(Datasnapshot.java:185) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.mycompany.parcelasdecartao.Mainactivity$100000001$100000000.onDataChange(Mainactivity.java:71) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.firebase.client.core.Valueeventregistration.fireEvent(Valueeventregistration.java:45) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.firebase.client.core.view.DataEvent.fire(Dataevent.java:45) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.firebase.client.core.view.Eventraiser$1.run(Eventraiser.java:38) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at android.os.Handler.handleCallback(Handler.java:746) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at android.os.Handler.dispatchMessage(Handler.java:95) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at android.os.Looper.loop(Looper.java:148) 09-01 19:15:53.574 21966 21966 E Androidruntime at android.app.Activitythread.main(Activitythread.java:5443) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at java.lang.reflect.Method.invoke(Native Method) 09-01 19:15:53.574 21966 21966 E Androidruntime at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:728) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:618) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
Caused by: com.fasterxml.Jackson.databind.exc.Unrecognizedpropertyexception: Unrecognized field "-Kszuqxlafg5qrtixqas" (class com.mycompany.parcelasdecartao.model.Person), not marked as ignorable (3 known properties: , "uid", "name", "address"]) 09-01 19:15:53.574 21966 21966 E Androidruntime at [Source: java.io.Stringreader@a 6ef5a3; line: 1, column: 56] (through Reference chain: com.mycompany.parcelasdecartao.model.Person["-Kszuqxlafg5qrtixqas"]) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.Deserializationcontext.reportUnknownProperty(Deserializationcontext.java:555) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.deser.std.Stddeserializer.handleUnknownProperty(Stddeserializer.java:708) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(Beandeserializerbase.java:1160) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.deser.BeanDeserializer.deserializeFromObject(Beandeserializer.java:315) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.deser.BeanDeserializer.deserialize(Beandeserializer.java:121) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.Objectmapper. _readMapAndClose(Objectmapper.java:2888) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.fasterxml.Jackson.databind.Objectmapper.readValue(Objectmapper.java:2034) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
at com.firebase.client.DataSnapshot.getValue(Datasnapshot.java:183) 09-01 19:15:53.574 21966 21966 E AndroidRuntime
... 11 more
Object
package com.mycompany.parcelasdecartao.model;
import com.google.firebase.database.*;
/**
* Created by Belal on 2/23/2016.
*/ //@JsonIgnoreProperties @IgnoreExtraProperties public class Person { //name and address string
private String name; private String address; @Exclude private String uid;
public Person() { /*Blank default constructor essential for Firebase*/ } //Getters and setters public String getUid(){ return uid; }
public void setUid(String uId) { this.uid = uId; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getAddress() { return address; }
public void setAddress(String address) { this.address = address; }
}
Código buttonSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
String personId; //Creating firebase object Firebase ref = new Firebase(Config.FIREBASE_URL);
//Getting values to store String name = editTextName.getText().toString().trim(); String address = editTextAddress.getText().toString().trim();
//Creating Person object Person person = new Person();
personId = ref.push().getKey();
//Adding values person.setName(name); person.setAddress(address); //person.setUid(personId);
//Storing values to firebase //ref.child("Person").setValue(person);
ref.child("Person").child(personId).setValue(person);
//Value event listener for realtime data update ref.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { for (DataSnapshot postSnapshot : snapshot.getChildren()) { //Getting the data from snapshot Person person = postSnapshot.getValue(Person.class);
//Adding it to a string String string = "Name: "+person.getName()+"\nAddress: "+person.getAddress()+"\n\n";
//Displaying it on textview textViewPersons.setText(string); } }
@Override public void onCancelled(FirebaseError firebaseError) { System.out.println("The read failed: " + firebaseError.getMessage()); } });
} });
}
Hello Oh, thank you for answering. I changed the code and now it works. Now I don’t know what to do with the question I asked. Should I replace the content with the new code? Any other options? Thanks again for your attention.
– UltraSeven
You up on my answer to say she helped you
– Oto Campos
@Ultraseven put the new code as a response. And mark it as accepted.
– Rosário Pereira Fernandes