Setting bottomTabs using setStackRoot crashes the android app, while it works perfectly fine for IOS. Below is an example of some code that would crash the android app.
```Navigation.setStackRoot('root', {
bottomTabs: {
id: 'HomeScreen',
children: [
{
stack: {
children: [
{
component: {
name: 'HomeInboxScreen',
passProps: {
text: 'This is tab 1',
},
},
},
],
options: {
bottomTab: {
text: 'Tab 1',
testID: 'FIRST_TAB_BAR_BUTTON',
icon: Images.icoAddAvatar,
},
},
},
},
{
component: {
name: 'HomePeopleScreen',
passProps: {
text: 'This is tab 2',
},
options: {
bottomTab: {
text: 'Tab 2',
testID: 'SECOND_TAB_BAR_BUTTON',
icon: Images.icoAddAvatar,
},
},
},
},
],
},
Please include crash log or pr a failing detox test
crash log on android:
NullPointerException: int com.reactnativenavigation.views.BottomTabs.getCurrentItem()' on a null object reference
Thanks @a396901990 - Can you please include the entire stack trace?
This is also happening in the latest release with RN 0.57
There's also a related issue here
Stacktrace from adb logcat:
--------- beginning of crash
10-29 10:17:00.126 10468 10468 E AndroidRuntime: FATAL EXCEPTION: main
10-29 10:17:00.126 10468 10468 E AndroidRuntime: Process: tate.mobile.energy, PID: 10468
10-29 10:17:00.126 10468 10468 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.reactnativenavigation.views.BottomTabs.getCurrentItem()' on a null object reference
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController.getCurrentChild(BottomTabsController.java:127)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ParentController.resolveCurrentOptions(ParentController.java:46)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ParentController.resolveCurrentOptions(ParentController.java:47)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ParentController.resolveCurrentOptions(ParentController.java:55)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.stack.StackController.push(StackController.java:150)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.stack.StackController.setRoot(StackController.java:188)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.lambda$setStackRoot$1(Navigator.java:151)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.-$$Lambda$Navigator$G3nUL8PMO8McOqIcItRVBC34GOg.run(Unknown Source:6)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.lambda$applyOnStack$5(Navigator.java:208)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.-$$Lambda$Navigator$fIU7KSJtjdT8n1yyuRKzJ5DC0qg.run(Unknown Source:2)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ViewController.performOnParentStack(ViewController.java:144)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.applyOnStack(Navigator.java:208)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.setStackRoot(Navigator.java:151)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.react.NavigationModule.lambda$setStackRoot$5(NavigationModule.java:96)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.reactnativenavigation.react.-$$Lambda$NavigationModule$LGRoJpgu47lI5G-vnzublv8HvGY.run(Unknown Source:10)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6863)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
10-29 10:17:00.126 10468 10468 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: FATAL EXCEPTION: main
10-29 10:18:36.847 11299 11299 E AndroidRuntime: Process: tate.mobile.energy, PID: 11299
10-29 10:18:36.847 11299 11299 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.reactnativenavigation.views.BottomTabs.getCurrentItem()' on a null object reference
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController.getCurrentChild(BottomTabsController.java:127)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ParentController.resolveCurrentOptions(ParentController.java:46)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ParentController.resolveCurrentOptions(ParentController.java:47)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ParentController.resolveCurrentOptions(ParentController.java:55)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.stack.StackController.push(StackController.java:150)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.stack.StackController.setRoot(StackController.java:188)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.lambda$setStackRoot$1(Navigator.java:151)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.-$$Lambda$Navigator$G3nUL8PMO8McOqIcItRVBC34GOg.run(Unknown Source:6)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.lambda$applyOnStack$5(Navigator.java:208)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.-$$Lambda$Navigator$fIU7KSJtjdT8n1yyuRKzJ5DC0qg.run(Unknown Source:2)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.ViewController.performOnParentStack(ViewController.java:144)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.applyOnStack(Navigator.java:208)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.viewcontrollers.navigator.Navigator.setStackRoot(Navigator.java:151)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.react.NavigationModule.lambda$setStackRoot$5(NavigationModule.java:96)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.reactnativenavigation.react.-$$Lambda$NavigationModule$LGRoJpgu47lI5G-vnzublv8HvGY.run(Unknown Source:10)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6863)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
10-29 10:18:36.847 11299 11299 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
temp workaround for myself
my guess is that when push is runned from stackcontroller, when we try to resolve options, it tries to get current view from bottomtabs controller, but at that point bottomtabs are not created yet, it happens later in getview():
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 Detox and report back. Thank you for your contributions.
This is still relevant and it also happens in version 2.1.3
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 Detox and report back. Thank you for your contributions.
Im using the same solution as @nezaidu (tabs.get(0)) And that makes it work for now.
Could someone with some android Exp find the issue and make a pull request ?
Thanks
I would close this issue https://github.com/wix/react-native-navigation/issues/4130 in favour of this one.
Yeah, that would be nice to find a solution...
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 Detox and report back. Thank you for your contributions.
The issue is still open...
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 Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.
Does this still not have a solution? Errors still happening for me with RN 59.8 and RNN 2.18.5... RNN is basically unusable if this isn't fixed...
Also failing for me...
Most helpful comment
my guess is that when push is runned from stackcontroller, when we try to resolve options, it tries to get current view from bottomtabs controller, but at that point bottomtabs are not created yet, it happens later in getview():

