question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoSuchMethodException while using FirebaseRecyclerAdapter

See original GitHub issue

I am using this library to show data in RecyclerView using FirebaseRecyclerAdapter. But app is crashing with the NoSuchMethodException.

My code is:

        mAdapter = new FirebaseRecyclerAdapter<TaskModel, TaskViewHolder>(TaskModel.class, R.layout.task_list_item, TaskViewHolder.class, firebase) {
            @Override
            protected void populateViewHolder(TaskViewHolder viewHolder, TaskModel model, int position) {
                Log.i("HOME", "populateViewHolder called");
            }
        };

        mRecyclerView.setAdapter(mAdapter);

View Helper class:

class TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

        private TextView mTimeTv;
        private TextView mTimeAmPm;
        private TextView mTaskTitleTv;

        private void findViews(View v) {
            mTimeTv = (TextView) v.findViewById(R.id.time_tv);
            mTimeAmPm = (TextView) v.findViewById(R.id.time_am_pm);
            mTaskTitleTv = (TextView) v.findViewById(R.id.task_title_tv);
        }

        public TaskViewHolder(View itemView) {
            super(itemView);
            findViews(itemView);
            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {

        }
    }

Please correct me if i am doing something wrong.

                                                                                 java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
                                                                                     at com.firebase.ui.FirebaseRecyclerAdapter.onCreateViewHolder(FirebaseRecyclerAdapter.java:168)
                                                                                     at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228)
                                                                                     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453)
                                                                                     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
                                                                                     at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
                                                                                     at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
                                                                                     at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
                                                                                     at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
                                                                                     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
                                                                                     at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:584)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
                                                                                     at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
                                                                                     at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:761)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983)
                                                                                    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:17

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:42 (7 by maintainers)

github_iconTop GitHub Comments

44reactions
pufcommented, Dec 27, 2015

There are two likely causes for this:

  1. make sure that your TaskViewHolder class is public
  2. if your TaskViewHolder is an inner class of e.g. your activity, make sure it’s static

So likely

public static TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
16reactions
kirtan403commented, Jul 15, 2016

pro-guard still caused crash… adding @Keep to the ViewHolder class solved for me…

Read more comments on GitHub >

github_iconTop Results From Across the Web

NoSuchMethodException while using FirebaseUI ...
I am trying to display the following JSON structure in a recyclerView using FirebaseUI and its recyclerAdapter.
Read more >
com.firebase.ui.database.FirebaseRecyclerAdapter Maven ...
See the README * for an in-depth tutorial on how to set up the FirebaseRecyclerAdapter. * * @param The Java class that maps...
Read more >
[Solved]-Recycler view is not displaying data from firebase using an ...
i want to favorite images from recycler view using Sql databse problem is that when i click on favorite button the table is...
Read more >
FirebaseRecyclerAdapter.java example - Javatips.net
This class describes the usage of FirebaseRecyclerAdapter.java. ... <p> * To use this class in your app, subclass it passing in all required...
Read more >
java lang nosuchmethodeexception, 线程main 中的异常'' java ...
NoSuchMethodException : onClick in list view on android , ... 我正在使用这个库使用FirebaseRecyclerAdapter 在RecyclerView 中显示数据。
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found