首页 > 解决方案 > android.support.v7.widget.RecyclerView$ViewHolder 的类文件

问题描述

我已更新我的应用程序以使用 androidx,从那时起我收到此错误:

class file for android.support.v7.widget.RecyclerView$ViewHolder

这是我的模块 buidle.gradle:

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'io.realm:android-adapters:3.1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
implementation 'com.google.android.gms:play-services-ads:19.8.0'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}

我有删除all reference to android.support.v7.widget.RecyclerView。我有另一个使用相同依赖项的应用程序,一切正常。

Andapter Studio 抱怨以下行:

public class MyAdapter extends RealmRecyclerViewAdapter<MyModel, MyViewHolder> {

和:Type parameter MyViewHolder is not with its bound. Should extend android.support.v7.widget.RecyclerView.ViewHolder

标签: androidandroid-recyclerviewrealm

解决方案


更新io.realm:android-adapters依赖:

implementation 'io.realm:android-adapters:4.0.0'

推荐阅读