No virtual method findViewHolderForPosition(I) when trying to click on RecyclerView item with Espresso

Ok, in my case problem was in ProGuard shrinking unused methods. Disabling it for tests helped.

For future seekers - if you don't want to disable proguard for debug build adding this line to proguard config should help too:

-keepclasseswithmembers public class android.support.v7.widget.RecyclerView { *; }

Also, note that this rule should be added to the regular proguard file(the one of listed in proguardFiles) and not the test one(declared as testProguardFile)


You can combine @Bersh's answer and this answer to be more strict about what to keep:

-keep class android.support.v7.widget.RecyclerView  {
    public android.support.v7.widget.RecyclerView$ViewHolder findViewHolderForPosition(int);
}

There is no reason to keep the entire RecyclerView class.

Update:

Or for when you inevitably update to AndroidX:

-keep class androidx.recyclerview.widget.RecyclerView  {
    public androidx.recyclerview.widget.RecyclerView$ViewHolder findViewHolderForPosition(int);
}