skydoves / PowerSpinner

🌀 A lightweight dropdown popup spinner, fully customizable with an arrow and animations for Android.
Apache License 2.0
1.22k stars 116 forks source link

App Crash on when using the spinner Android 6 and below #40

Closed basemosama closed 4 years ago

basemosama commented 4 years ago

Please complete the following information:

Describe the Bug:

Hello, There's a bug that is being reported by crashlytics on Android 5 and 6 and I faced when testing on Android 4.4 that causes the app to crash when using the spinner. it's working fine on Android 10 and Android 8 this the logcat

    java.lang.NullPointerException
        at android.widget.PopupWindow.update(PopupWindow.java:1375)
        at com.skydoves.powerspinner.PowerSpinnerView$updateSpinnerWindowSize$1.run(PowerSpinnerView.kt:496)
        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:5017)
        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:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

Is there any fix for this problem as I am getting multiple crashes on Android 5 and 6. Thanks.

skydoves commented 4 years ago

Hi, @basemosama. The crash would occur when we call setItems or setSpinnerAdapter before the PowerSpinnerView is initialized. It seems to be called after finish inflating.

powerspinnerView.post {
  setItems(..)
}
basemosama commented 4 years ago

yes, the problem happens when I use setItems or app:spinner_item_array it works fine in Android 10 and 11 but when I tested it on Android 6 and 4.4 it causes the app to crash. Is it a problem with the library or is there something wrong on my implementation ?

skydoves commented 4 years ago

Hi, @basemosama. I just found the issue in the library, It will be fixed in the next release! Thank you for your reporting :)

skydoves commented 4 years ago

Released a new version 1.1.4. Thanks!

basemosama commented 4 years ago

Nice, Thanks for the quick update.