Didn't find class "android.view.View$OnUnhandledKeyEventListener"
Android studio 使用androidX后应用启动log中报Didn’t find class “android.view.View$OnUnhandledKeyEventListener”
Log如下: 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn’t find class “android.view.View$OnUnhandledKeyEventListener” on path: DexPathList[[zip file “/data/app/application-_bN00Pj–ZAWz8avSM23Sw==/base.apk”],nativeLibraryDirectories=[/data/app/application-_bN00Pj–ZAWz8avSM23Sw==/lib/arm64, /data/app/application-_bN00Pj–ZAWz8avSM23Sw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /product/lib64]] 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:779) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:659) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(android.view.View) (AppCompatDelegateImpl.java:543) 2021-09-30 16:54:37.663 15046-15046/application I/zygote64: at void androidx.appcompat.app.AppCompatActivity.setContentView(android.view.View) (AppCompatActivity.java:166)
解决方案: 找到app moudle中引用 androidx.appcompat:appcompat 的地方, 将版本号由1.1.0 升级为1.3.0, git diff 如下:
diff --git a/app/build.gradle b/app/build.gradle index 3c22c0f…17b4a53 100644 — a/app/build.gradle +++ b/app/build.gradle @@ -84,7 +84,7 @@ static def releaseTime() { }
dependencies {
- implementation ‘androidx.appcompat:appcompat:1.1.0’
- implementation ‘androidx.appcompat:appcompat:1.3.0’
|