我在android的xml布局文件中使用了android support v7 recyclerView
<android.support.v7.widget.RecyclerView
android:id="@+id/messagelist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:clipToPadding="false"
android:scrollbars="vertical" />
我切换到androidx,所以我将回收站视图更改为androidx recyclerView,如下所示:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/messagelist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:clipToPadding="false"
android:scrollbars="vertical" />
所以我收到此错误:
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.yassineghr.chatdemov2-2/base.apk"],nativeLibraryDirectories=[/data/app/com.yassineghr.chatdemov2-2/lib/x86, /system/lib, /vendor/lib]]
这是我的gradle构建文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.yassineghr.chatdemov2"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "androidx") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "${targetSdk}.+"
}
}
}
}
}