Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
uni-cstar opened this issue Dec 19, 2022 · 2 comments
Closed

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

uni-cstar opened this issue Dec 19, 2022 · 2 comments

Comments

@uni-cstar
Copy link

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) 

@uni-cstar
Copy link
Author

#1072

@junixapp
Copy link
Owner

更新到2.9.18即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants