3

I have user class like this

public class User{
int id;
String description;
String shortDescription;
String photo;

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public String getShortDescription() {
    return shortDescription;
}

public void setShortDescription(String shortDescription) {
    this.shortDescription = shortDescription;
}

public String getPhoto() {
    return photo;
}

public void setPhoto(String photo) {
    this.photo = photo;
}
}

i am fetching the user stored on my firebase using the FirebaseRecyclerAdapter like as shown below

 FirebaseRecyclerAdapter<User, UserHolder> adapter =
            new FirebaseRecyclerAdapter<User, UserHolder>(
                    User.class,
                    android.R.layout.two_line_list_item,
                    UserHolder.class,
                    mRef) {
                @Override
                protected void populateViewHolder(UserHolder userHolder, User u, int i) {
                    userHolder.mText.setText(u.getDescription());
                }
            };

But the issue is is when the firebase key of the user object is like

 > -KDY9Pna7XqgFkyCHKFJ

this then its working fine but if the firebase key is like

 > c5755a68-69a7-4464-956e-c2f94d9b387d

this unique id then it is giving an error

> com.firebase.client.FirebaseException: Failed to bounce to type
FATAL EXCEPTION: 
main Process: in.rofr, PID: 12399
com.firebase.client.FirebaseException: Failed to bounce to type
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
at com.firebase.ui.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:161)
at com.firebase.ui.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:150)
at com.firebase.ui.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:190)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5465)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5498)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4735)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4611)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1988)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1347)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3026)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2903)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3277)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1183)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15689)
at android.view.ViewGroup.layout(ViewGroup.java:5040)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2116)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)

What is the exact issue, i am not getting can anyone help me?

Thanks in advance !!!

5
  • can i know what is s in this line userHolder.mText.setText(s.getDescription()); i dnt find where did you declare that one. Commented Mar 23, 2016 at 12:00
  • sorry its u.getDescription() Commented Mar 23, 2016 at 12:01
  • Still little confuse, Can you tell about key. is that key in firebase or key of Object while debug ? Commented Mar 23, 2016 at 12:18
  • Well the problem is JSON property does not maps correctly please look this Answer Commented Mar 23, 2016 at 12:51
  • Without seeing a user in JSON (as text, no screenshot please) and the full stack trace (the more interesting error message is nested) it will be impossible to help. But the answer @Kathi linked is indeed a good start. :-) Commented Mar 23, 2016 at 16:30

1 Answer 1

5

Try putting @JsonIgnoreProperties(ignoreUnknown = true) on top of the class like this

@JsonIgnoreProperties(ignoreUnknown = true)
public class UserModel {

}

This might work because Firebase uses Jackson library to serialise/deserialise JSON and the use of @JsonIgnoreProperties(ignoreUnknown = true) is to ignore new properties (properties that are not declared in the class) as stated here https://stackoverflow.com/a/5455563/2331705

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.