java.lang.NullPointerException: Attempt to read from field 'com.reactnativenavigation.parse.TopBarOptions com.reactnativenavigation.parse.Options.topBar' on a null object reference
Issue Description
Fresh installation crashes on Android only with the error:
java.lang.NullPointerException: Attempt to read from field 'com.reactnativenavigation.parse.TopBarOptions com.reactnativenavigation.parse.Options.topBar' on a null object reference .
Environment
- React Native Navigation version: 2.26.0
- React Native version: 0.59.10
- Platform(s) (iOS, Android, or both?): Android
- Device info (Simulator/Device? OS version? Debug/Release?): ALL
Same issue after fresh install on React Native 0.60.4 and using React Native Navigation 3.0.0-alpha.7.
I was able to bypass the issue by changing, in com/reactnativenavigation/parse/Options.java:
public Options withDefaultOptions(final Options defaultOptions) {
topBar.mergeWithDefault(defaultOptions.topBar);
topTabOptions.mergeWithDefault(defaultOptions.topTabOptions);
topTabs.mergeWithDefault(defaultOptions.topTabs);
bottomTabOptions.mergeWithDefault(defaultOptions.bottomTabOptions);
bottomTabsOptions.mergeWithDefault(defaultOptions.bottomTabsOptions);
fabOptions.mergeWithDefault(defaultOptions.fabOptions);
animations.mergeWithDefault(defaultOptions.animations);
sideMenuRootOptions.mergeWithDefault(defaultOptions.sideMenuRootOptions);
modal.mergeWithDefault(defaultOptions.modal);
statusBar.mergeWithDefault(defaultOptions.statusBar);
layout.mergeWithDefault(defaultOptions.layout);
transitions.mergeWithDefault(defaultOptions.transitions);
return this;
}
Into this:
if (defaultOptions != null) {
topBar.mergeWithDefault(defaultOptions.topBar);
topTabOptions.mergeWithDefault(defaultOptions.topTabOptions);
topTabs.mergeWithDefault(defaultOptions.topTabs);
bottomTabOptions.mergeWithDefault(defaultOptions.bottomTabOptions);
bottomTabsOptions.mergeWithDefault(defaultOptions.bottomTabsOptions);
fabOptions.mergeWithDefault(defaultOptions.fabOptions);
animations.mergeWithDefault(defaultOptions.animations);
sideMenuRootOptions.mergeWithDefault(defaultOptions.sideMenuRootOptions);
modal.mergeWithDefault(defaultOptions.modal);
statusBar.mergeWithDefault(defaultOptions.statusBar);
layout.mergeWithDefault(defaultOptions.layout);
transitions.mergeWithDefault(defaultOptions.transitions);
}
return this;
}
But since I'm way over my head here I wouldn't recommend shipping anything with this code. It's just something to get it up and running until a real solution is found.
Any help would be much appreciated!
@eduardopelitti Sorry for the confusion, my mistake. fixed in alpha.8
I'm getting the same error using React-native 0.59.10 && react-native-navigation ^2.26.0 If someone could help me, it would be great Thanks
@ZeitounCorp, looks like it was a bug, u can fix it by setting :
Navigation.setDefaultOptions({
topBar: {
}
})