Api 28 class 从androidx的支持库调用

Api 28 class is called from androidx's support library

我在 android phone 上尝试 运行 调试模式时收到此消息。

应用程序找不到 OnUnhandledKeyEventListener 是合理的,因为它是在 api 28 和我的 phone 运行s api 27 中添加的,但是为什么它甚至尝试,当它应该是一个支持库?这是库中的错误还是我遗漏了什么?即使您创建空的 android studio 项目并进行重构 -> 迁移到 AndroidX

,也会发生这种情况
    I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2422)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:141)
        at void com.infradev.lessontimer.LoginActivity.onCreate(android.os.Bundle) (LoginActivity.java:25)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7084)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7075)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2767)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1613)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:171)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6635)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/base.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_resources_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_5_apk.apk", zip file "/data/ap
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2422)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:141)
        at void com.infradev.lessontimer.LoginActivity.onCreate(android.os.Bundle) (LoginActivity.java:25)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7084)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7075)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2767)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1613)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:171)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6635)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)
    Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2422)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:141)
        at void com.infradev.lessontimer.LoginActivity.onCreate(android.os.Bundle) (LoginActivity.java:25)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7084)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7075)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2767)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1613)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:171)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6635)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/base.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_resources_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_5_apk.apk", zip file "/data/ap
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2422)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:141)
        at void com.infradev.lessontimer.LoginActivity.onCreate(android.os.Bundle) (LoginActivity.java:25)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7084)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7075)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2767)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1613)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:171)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6635)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)
I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2422)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:141)
        at void com.infradev.lessontimer.LoginActivity.onCreate(android.os.Bundle) (LoginActivity.java:25)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7084)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7075)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2767)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1613)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:171)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6635)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/base.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_resources_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.infradev.lessontimer-oANosPd_Q6S3fKsdUvgGLg==/split_lib_slice_5_apk.apk", zip file "/data/ap
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2422)
        at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
        at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
        at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
        at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:141)
        at void com.infradev.lessontimer.LoginActivity.onCreate(android.os.Bundle) (LoginActivity.java:25)
        at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7084)
        at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7075)
        at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1215)
        at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2767)
        at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
        at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1613)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:171)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6635)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:547)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:823)

Is it a bug in library or I'm missing something?

这是来自合子 (I/zygote64) 的信息消息。这不是错误。没有错。

当加载了引用了无法识别的符号 (View.OnUnhandledKeyEventListener) 的 class (ViewCompat) 时,即使代码不会尝试使用这些符号。