My app is a tab-based app with various pushed screens and modals. Currently (and only on android), we have several areas of the app where a screen is pushed, and a modal is shown over the pushed screen. In all areas where this is the case, calling dismissAllModals()
results in an app crash.
java.lang.NullPointerException: Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference
at com.aurelhubert.ahbottomnavigation.AHBottomNavigation.setTitleInactiveTextSizeInSp(AHBottomNavigation.java:1184)
at com.reactnativenavigation.presentation.BottomTabPresenter.applyOptions(BottomTabPresenter.java:55)
at com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController.applyOptions(BottomTabsController.java:90)
at com.reactnativenavigation.viewcontrollers.ViewController.onViewAppeared(ViewController.java:206)
at com.reactnativenavigation.viewcontrollers.ChildController.onViewAppeared(ChildController.java:34)
at com.reactnativenavigation.viewcontrollers.ViewController.onGlobalLayout(ViewController.java:259)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:945)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2250)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
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:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
export const goToContestInfo = (rootId, contestId) => {
Navigation.push( rootId, {
component: {
name: 'contestInfo',
passProps: {
contestId,
},
options: {
bottomTabs: { visible: false , drawBehind: true, animate:true},
topBar: {
title: {
text: 'INFO',
color: 'white'
},
visible: true,
buttonColor: "white",
backButton: {
visible: true,
color:"white",
icon: getBackArrow(),
},
background:{
color: COLORS.dark
},
}
},
}
})
};
export const goToGenericWebView = ( source ) => {
Navigation.showModal({
stack: {
children: [
{
component: {
name: "genericWebView",
passProps:{
source
},
options:{
overlayPresentationStyle: "overCurrentContext",
topBar: {
title: {
component:{
name:'logoHeader',
alignment: 'center',
}
},
visible:true,
background: {
color: COLORS.dark
},
rightButtons:[
{
id:"closeWebViewModal",
component: {
name: 'iconButton',
passProps:{
onPress: () => {
Navigation.dismissAllModals()
},
source:closeButton,
}
}
}
]
}
},
}
}
]
}
})
}
Has anyone been able to reproduce this? I've spent a lot of time trying to troubleshoot this from the JS end and had no luck. As a temporary fix, I went into BottomTabPresenter.java
and commented out line 55: bottomTabs.setTitleInactiveTextSizeInSp(i, tab.fontSize.hasValue() ? Float.valueOf(tab.fontSize.get()) : null);
and the program runs as expected. We don't use an inactive text size on the tabs, but I imagine this won't work for people who do.
Also, I looked at https://github.com/aurelhubert/ahbottomnavigation/blob/master/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java and it looks like in a more recent version they've changed the class slightly with regard to these functions.
in the version you're using, getInactiveTextSize
and getActiveTextSize
are slightly different. The inactive text size function doesn't have the .floatValue()
casting function. It seems like this could be the problem?
Same problem.
mdermksian's solution works for me.
I have found a simple solution for this problem. Just add tab style (i.e fontSize and other styles ) to the pushed screen even if the tab is hidden. This could solve the app crash problem without touching the native java code
+1
@Siddharth-Stark could you please put an example of what are you doing?
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.
Not stale! I believe this is being worked on and should not yet be closed
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.
@Siddharth-Stark could you please put an example of what are you doing?
You can add static navigation options like in the pushed screen
static options(passProps) {
return {
bottomTabs: {
visible: false,
animate: false,
drawBehind: true,
},
bottomTab: {
fontSize: 11,
},
}
}
Even if tabs are hidden, you should just add tab font size in the options.. this prevents crash without modifying any native code.
The problem not solved yet.
Do you need any more informations?
Same here
Environment
The problem is solved by adding
options: {
bottomTab: {
fontSize: 12,
}
}
to the pushed screen where you add then dismiss modal.
Basically, when you push screen (without specifying fontSize of bottomTab) -> add modal -> dismiss modal, will crash with logcat error at : at com.aurelhubert.ahbottomnavigation.AHBottomNavigation.setTitleInactiveTextSizeInSp(AHBottomNavigation.java:1184)
I'm still stuck with this problem:
Navigation.showModal({
stack: {
children: [{
component: {
name: 'containers-app.ContainersConfigureDeviceScreen',
passProps: {
claimCode: claimCode
},
options: {
topBar: {
title: {
text: 'Configurar Dispositivo'
},
leftButtons: [
{
id: 'cancelDeviceConfiguration',
icon: res
}
],
},
bottomTabs: {
visible: false,
animate: false,
drawBehind: true,
},
bottomTab: {
fontSize: 11,
},
}
}
}]
}
});
That is the code i'm using in order to prevent the crash on android but it is not working
@Jatapiaro you don't have to add bottomTab prop to Navigation.showModal. You have to add it to the pushed screen (inside Navigation.push) where you adding then dismissing modals.
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.
This issue should not be staled because its not yet fixed
Most helpful comment
Has anyone been able to reproduce this? I've spent a lot of time trying to troubleshoot this from the JS end and had no luck. As a temporary fix, I went into
BottomTabPresenter.java
and commented out line 55:bottomTabs.setTitleInactiveTextSizeInSp(i, tab.fontSize.hasValue() ? Float.valueOf(tab.fontSize.get()) : null);
and the program runs as expected. We don't use an inactive text size on the tabs, but I imagine this won't work for people who do.