2
I’m trying to requisition an app for firebase. I can save data in the database normally, but when retrieving it, I find the following error:
06-20 12:07:15.151 28158-28158/sgk.com.br.sgk E/Androidruntime: FATAL EXCEPTION: main Process: sgk.com.br.sgk, PID: 28158 com.firebase.client.Firebaseexception: Failed to Bounce to type at com.firebase.client.DataSnapshot.getValue(Datasnapshot.java:183) at sgk.com.br.sgk.Activity.Greattrainsactivity$1.onDataChange(Greattrainsactivity.java:65) com.firebase.client.core.Valueeventregistration.fireEvent(Valueeventregistration.java:45) at com.firebase.client.core.view.DataEvent.fire(Dataevent.java:45) at com.firebase.client.core.view.Eventraiser$1.run(Eventraiser.java:38) at android.os.Handler.handleCallback(Handler.java:746) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.Activitythread.main(Activitythread.java:5443) at java.lang.reflect.Method.invoke(Native Method) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:728) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:618) Caused by: com.fasterxml.Jackson.databind.exc.Unrecognizedpropertyexception: Unrecognized field "vdsrXOFXRZbAfmoEQ3WEVB1GDDa2" (class sgk.com.br.sgk.Others.Train), not marked as ignorable (2 known properties: "Description", "local"]) at [Source: java.io.Stringreader@ab 8ad7; line: 1, column: 34] (through Reference chain: sgk.com.br.sgk.Others.Train["vdsrXOFXRZbAfmoEQ3WEVB1GDa2"]) at com.fasterxml.Jackson.databind.Deserializationcontext.reportUnknownProperty(Deserializationcontext.java:555) at com.fasterxml.Jackson.databind.deser.std.Stddeserializer.handleUnknownProperty(Stddeserializer.java:708) with.fasterxml.Jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(Beandeserializerbase.java:1160) at com.fasterxml.Jackson.databind.deser.BeanDeserializer.deserializeFromObject(Beandeserializer.java:315) with.fasterxml.Jackson.databind.deser.BeanDeserializer.deserialize(Beandeserializer.java:121) at com.fasterxml.Jackson.databind.Objectmapper. _readMapAndClose(Objectmapper.java:2888) at com.fasterxml.Jackson.databind.Objectmapper.readValue(Objectmapper.java:2034) at com.firebase.client.DataSnapshot.getValue(Datasnapshot.java:181) at sgk.com.br.sgk.Activity.Greattrainsactivity$1.onDataChange(Greattrainsactivity.java:65) com.firebase.client.core.Valueeventregistration.fireEvent(Valueeventregistration.java:45) at com.firebase.client.core.view.DataEvent.fire(Dataevent.java:45) at com.firebase.client.core.view.Eventraiser$1.run(Eventraiser.java:38) at android.os.Handler.handleCallback(Handler.java:746) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.Activitythread.main(Activitythread.java:5443) at java.lang.reflect.Method.invoke(Native Method)
This is my code
Firebase.setAndroidContext(this);
Firebase ref = new Firebase(Constants.FIREBASE_URL);
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
//Getting the data from snapshot
Train train = postSnapshot.getValue(Train.class);
//Adding it to a string
String string = "Local: " + train.getLocal() + "\nDescrição: " + train.getDescription() + "\n\n";
//Displaying it on textview
textViewPersons.setText(string);
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
And this is my POJO
public class Train {
private String local;
private String description;
public Train() {
}
public String getLocal() {
return local;
}
public void setLocal(String local) {
this.local = local;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
Gee, vei, new technology, I took the implementation because I had problems, published the new verses without it, I’ll wait a few more days to update with the api... if Voce solve, post here, can help and much...
– Armando Marques Sobrinho