当前位置:   article > 正文

androidx下报错 Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener_androidx.core.view.viewcompat$2

androidx.core.view.viewcompat$2

升级 AndroidStudio 以后,默认compileSdkVersion为30,APP运行后报这个错,但不闪退。

  1. 2021-06-03 10:22:21.478 9096-9096/com.example.mlkitdemo I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
  2. 2021-06-03 10:22:21.478 9096-9096/com.example.mlkitdemo I/zygote64: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2678)
  3. //......
  4. //......
  5. 2021-06-03 10:22:21.478 9096-9096/com.example.mlkitdemo I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.mlkitdemo-yUuuSCpq49HIzilKv738Ow==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.mlkitdemo-yUuuSCpq49HIzilKv738Ow==/lib/arm64, /data/app/com.example.mlkitdemo-yUuuSCpq49HIzilKv738Ow==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]

有两种解决办法:

方法一: 降低sdk版本号。

但只能修改到28,修改为27及以下会报错

AAPT: error: style attribute 'android:attr/dialogCornerRadius' not found.

方法二: 修改appcompat版本

implementation 'androidx.appcompat:appcompat:1.3.0-rc01'

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号