Skip to content

在4.4的设备上运行出错 #1071

@uni-cstar

Description

@uni-cstar

XPopup版本
2.9.16

手机系统和型号
4.4系统设备

描述你的问题
出错的核心代码:

在BasePopupView#attachToHost 方法执行以下代码时抛出:
((FragmentActivity) getContext()).getLifecycle().addObserver(this);

查到类似原因:
https://www.coder.work/article/676482

出错堆栈:
java.lang.IllegalArgumentException: The observer class has some methods that use newer APIs which are not available in the current OS version. Lifecycles cannot access even other methods so you should make sure that your observer classes only access framework classes that are available in your min API level OR use lifecycle:compiler annotation processor.
at androidx.lifecycle.ClassesInfoCache.getDeclaredMethods(ClassesInfoCache.java:76)
at androidx.lifecycle.ClassesInfoCache.hasLifecycleMethods(ClassesInfoCache.java:54)
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:167)
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148)
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:175)
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148)
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:175)
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148)
at androidx.lifecycle.Lifecycling.lifecycleEventObserver(Lifecycling.java:84)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.(LifecycleRegistry.java:347)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:174)
at com.lxj.xpopup.core.BasePopupView.attachToHost(BasePopupView.java:136)
at com.lxj.xpopup.core.BasePopupView.access$000(BasePopupView.java:58)
at com.lxj.xpopup.core.BasePopupView$1.run(BasePopupView.java:120)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5030)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:863)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: android/view/WindowInsets
at java.lang.Class.getDeclaredMethods(Native Method)
at java.lang.Class.getDeclaredMethods(Class.java:656)
at androidx.lifecycle.ClassesInfoCache.getDeclaredMethods(ClassesInfoCache.java:74)
at androidx.lifecycle.ClassesInfoCache.hasLifecycleMethods(ClassesInfoCache.java:54) 
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:167) 
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148) 
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:175) 
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148) 
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:175) 
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148) 
at androidx.lifecycle.Lifecycling.lifecycleEventObserver(Lifecycling.java:84) 
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.(LifecycleRegistry.java:347) 
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:174) 
at com.lxj.xpopup.core.BasePopupView.attachToHost(BasePopupView.java:136) 
at com.lxj.xpopup.core.BasePopupView.access$000(BasePopupView.java:58) 
at com.lxj.xpopup.core.BasePopupView$1.run(BasePopupView.java:120) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5030) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:863) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.WindowInsets" on path: DexPathList[[zip file "/data/app/com.insight.twnormaltv-2.apk", dex file "dalvik.system.DexFile@4250d0c0", dex file "dalvik.system.DexFile@424ad840", dex file "dalvik.system.DexFile@42665190", dex file "dalvik.system.DexFile@426260e8"],nativeLibraryDirectories=[/data/app-lib/com.insight.twnormaltv-2, /system/lib, /vendor/lib, /system/lib/egl]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at java.lang.Class.getDeclaredMethods(Native Method) 
at java.lang.Class.getDeclaredMethods(Class.java:656) 
at androidx.lifecycle.ClassesInfoCache.getDeclaredMethods(ClassesInfoCache.java:74) 
at androidx.lifecycle.ClassesInfoCache.hasLifecycleMethods(ClassesInfoCache.java:54) 
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:167) 
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148) 
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:175) 
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148) 
at androidx.lifecycle.Lifecycling.resolveObserverCallbackType(Lifecycling.java:175) 
at androidx.lifecycle.Lifecycling.getObserverConstructorType(Lifecycling.java:148) 
at androidx.lifecycle.Lifecycling.lifecycleEventObserver(Lifecycling.java:84) 
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.(LifecycleRegistry.java:347) 
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:174) 
at com.lxj.xpopup.core.BasePopupView.attachToHost(BasePopupView.java:136) 
at com.lxj.xpopup.core.BasePopupView.access$000(BasePopupView.java:58) 
at com.lxj.xpopup.core.BasePopupView$1.run(BasePopupView.java:120) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5030) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:863) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
at dalvik.system.NativeStart.main(Native Method) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions