RecyclerView ClassNotFound

If you're looking for solution in 2019, you could try to change android.support.v7.widget.RecyclerView for androidx.recyclerview.widget.RecyclerView. It works for me. Hope it helps!


you can use androidx recyclerview widget, this works !

 <androidx.recyclerview.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:scrollbars="vertical"
    android:id="@+id/listExp"
    />

and import to code,

import androidx.recyclerview.widget.RecyclerView;

and then ready to use ,

 private RecyclerView recyclerViewExp;

I did all what have been said in this post but nothing worked.

What did work for me:

1.Add this as say up in your build.gradle:

compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'

2.Add the RecyclerView as a standar View and indicate the class:

    <view
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="android.support.v7.widget.RecyclerView"
    android:id="@+id/my_recycler_view"
    />

3.Then add the imports:

import android.support.v7.widget.RecyclerView;

Hope this helps!


Problem in your layout. Change

<RecyclerView 
   ...

To

<android.support.v7.widget.RecyclerView
   ...

If you create RecyclerView programmatically - make sure you have proper import:

import android.support.v7.widget.RecyclerView;

Tags:

Android