react-native-pager-view: KotlinNullPointerException

Environment

“react-native-pager-view”: “^5.1.2” OnePlus 8T Android 11 (SDK 30)

Issue

com.reactnativepagerview.PagerViewViewManager.createViewInstance

kotlin.KotlinNullPointerException: 
  at com.reactnativepagerview.PagerViewViewManager.createViewInstance (PagerViewViewManager.kt:30)
  at com.reactnativepagerview.PagerViewViewManager.createViewInstance (PagerViewViewManager.kt:21)
  at com.facebook.react.uimanager.ViewManager.createViewInstance (ViewManager.java:139)
  at com.facebook.react.uimanager.ViewManager.createView (ViewManager.java:82)
  at com.facebook.react.uimanager.NativeViewHierarchyManager.createView (NativeViewHierarchyManager.java:269)
  at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute (UIViewOperationQueue.java:179)
  at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:773)
  at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:888)
  at com.facebook.react.uimanager.UIViewOperationQueue.access$2200 (UIViewOperationQueue.java:42)
  at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded (UIViewOperationQueue.java:846)
  at com.facebook.react.bridge.GuardedRunnable.run (GuardedRunnable.java:29)
  at android.os.Handler.handleCallback (Handler.java:883)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:214)
  at android.app.ActivityThread.main (ActivityThread.java:7710)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:516)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)

This is the error I’m getting from the google play console

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 15
  • Comments: 27 (8 by maintainers)

Most upvoted comments

We still have the crash on production.

Packages versions:

"react-native": "0.64.0"
"react-native-pager-view": "5.2.1"
"react-native-tab-view": "3.0.1"

Hermes: true

2021-06-23_14-17

@troZee I found one reliable way to replicate this bug.

Have the pager render behind the Android permission request popup.

For me, when I start my app, it requests for an Android permission immediately. Behind the popup, I see my app rendering and it crashes as soon as it tries to render the pager stuff. If I dismiss it (i.e. Allow or deny the permission) quick enough, it will not crash

Good news! It has been about one week after I pushed an app update. So far we longer see the crash!

@cojj90

For now, as a workaround, we added an explicit check in JS to check for Android activity before rendering pager-view

Could you provide a code snippet of that solution ? I would like to take a look on it.