janheinrichmerker/material-intro

Crash due to NPE

Opened this issue · 5 comments

The following is the stack trace from my crashlytics console

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.VelocityTracker.addMovement(android.view.MotionEvent)' on a null object reference
       at androidx.viewpager.widget.ViewPager.fakeDragBy(ViewPager.java:2626)
       at com.heinrichreimersoftware.materialintro.app.IntroActivity$5.fakeDragToPosition(IntroActivity.java:402)
       at com.heinrichreimersoftware.materialintro.app.IntroActivity$5.onAnimationUpdate(IntroActivity.java:384)
       at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1522)
       at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1316)
       at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1446)
       at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
       at android.animation.AnimationHandler.-wrap2(AnimationHandler.java)
       at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
       at android.view.Choreographer.doCallbacks(Choreographer.java:725)
       at android.view.Choreographer.doFrame(Choreographer.java:657)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:899)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6548)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)

Till now, I have received crashes on Oppo, Samsung, Xiaomi, G_TOUCH devices on Android 6, 8, and 9.

I have no idea why this must be happening, and the above stack trace is the only information I have. I was unable to find a solution on the net.

The only conclusion I was able to draw was that when fakeDragToPosition is called by material-intro, then the function calls ViewPager.fakeDragBy, which calls mVelocityTracker.addMovement(ev). For some reason, the mVelocityTracker object is null.
Can you please look into this?

There are some internal issues in ViewPager.
Maybe we should move to ViewPager2.

Some of my users are still having this problem so I'm going to work on a fix. Does anyone know how to reproduce it?