AppIntro / AppIntro

Make a cool intro for your Android app.
Apache License 2.0
10.51k stars 1.77k forks source link

IndexOutOfBoundsException from time to time #1059

Closed rfc2822 closed 1 year ago

rfc2822 commented 1 year ago

🐛 Describe the bug

We use AppIntro in our app (https://github.com/bitfireAT/davx5). The slides are created dynamically in onCreate(). Which slides are shown depends on various conditions.

⚠️ Current behavior

Everything is working fine, but there are mysterious app crashes in Google Play that don't go away. Stack trace:

java.lang.IndexOutOfBoundsException: 
  at java.util.ArrayList.get (ArrayList.java:437)
  at com.github.appintro.internal.viewpager.PagerAdapter.getItem (PagerAdapter.kt:14)
  at com.github.appintro.AppIntroBase$onPostCreate$1.run (AppIntroBase.kt:458)
  at android.os.Handler.handleCallback (Handler.java:883)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8167)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)

Unfortunately, I couldn't reproduce this crash until now. Do you maybe have an idea how I could do that?

✅ Expected behavior

AppIntroBase shouldn't crash. If a fragment is not found in the list (for whatever reason), this should be handled gracefully.

📱 Tech info

cortinico commented 1 year ago

Sadly without a reproducer that's impossible to effectively fix :(

rfc2822 commented 1 year ago

I agree and I have already tried to reproduce it but no idea how to do it (especially because the stack trace only contains AppIntro lines)… maybe gracefully handling the exception would at least prevent apps (including other apps) from crashing

cortinico commented 1 year ago

I believe the best approach here would be to migrate to ViewPager 2 which @paolorotolo was looking itno doing

paolorotolo commented 1 year ago

This should be fixed in AppIntro 7.0.0 (Beta) which uses ViewPager2. Please feel free to reopen the issue if it still occurs. Thanks!