React-native-navigation: Attempt to invoke virtual method 'void com.reactnativenavigation.viewcontrollers.ViewController.onViewWillAppear()' on a null object reference

Created on 18 Sep 2018  ·  12Comments  ·  Source: wix/react-native-navigation

Issue Description

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.reactnativenavigation.viewcontrollers.ViewController.onViewWillAppear()' on a null object reference

Steps to Reproduce / Code Snippets / Screenshots

Switch between screens:

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.reactnativenavigation.viewcontrollers.ViewController.onViewWillAppear()' on a null object reference
    at com.reactnativenavigation.viewcontrollers.stack.StackController.pop(StackController.java:203)
    at com.reactnativenavigation.viewcontrollers.stack.StackController.onNavigationButtonPressed(StackController.java:318)
    at com.reactnativenavigation.viewcontrollers.stack.StackController.bridge$lambda$0$StackController(StackController.java)
    at com.reactnativenavigation.viewcontrollers.stack.StackController$$Lambda$0.onPress
    at com.reactnativenavigation.viewcontrollers.TitleBarButtonController.lambda$null$0$TitleBarButtonController(TitleBarButtonController.java:102)
    at com.reactnativenavigation.viewcontrollers.TitleBarButtonController$$Lambda$3.onClick
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22433)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6186)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

Environment

  • React Native Navigation version: 2.0.2544
  • React Native version: 55.4
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Device, 7.1.2, Release
🏚 stale

Most helpful comment

In my case I was defining a route id, so whenever a route with the same id is pushed several times into the stack caused me to get such an error when doing pop. Not defining the route id fixed it for me.

All 12 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

The issue has been closed for inactivity.

save issues

same issue here
image

Also having this issue

  • React Native Navigation version: 2.1.3
  • React Native version: 57.5
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): All android devices, both debug and release

I can also reproduce this in 2.12.0.

In my case this is reproduceable by simply doing the same push -> push -> pop -> pop 3-4 times

same here

In my case I was defining a route id, so whenever a route with the same id is pushed several times into the stack caused me to get such an error when doing pop. Not defining the route id fixed it for me.

In my case I was defining a route id, so whenever a route with the same id is pushed several times into the stack caused me to get such an error when doing pop. Not defining the route id fixed it for me.

Can you explain what do you mean by route id?

Still an issue

It seems that trying to pop a screen that got pushed multiple times is indeed the issue @shuuha.
In my case it was enough to pop the screen once every time before re pushing it.

In my case I was defining a route id, so whenever a route with the same id is pushed several times into the stack caused me to get such an error when doing pop. Not defining the route id fixed it for me.

Can you explain what do you mean by route id?

Navigation.push(componentId, {
component: {
// id: SOME_SCREEN, <-- this is the route id shuuha is talking abt
name: SOME_SCREEN
}
});


it fixed for me too..

Was this page helpful?
0 / 5 - 0 ratings