react-native-screens: Crash on Android with react-navigation stack
When I navigate to this specific screen the app is crashing.
It works fine on iOS and it works fine if I comment out enableScreens() and not use react-native-screens
It’s a pretty standard screen, apollo hooks + SectionList and some Text View TouchableOpacity (from react-native-gesture-handler)
Here is the log collected by Sentry, is there anything I can do to debug and help finding the root cause?
java.lang.IllegalStateException: Fragment already added: ScreenFragment{e9e00a9 (89d81b03-c200-4966-881c-38bb9e88da42) id=0x175}
at androidx.fragment.app.FragmentManagerImpl.addFragment(FragmentManagerImpl.java:1379)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:399)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 19
- Comments: 29 (9 by maintainers)
Same issue with react-navigation v5 and react-native-screens v2.0.0-beta.2 Happens when going back to previous screen
Quick workaround for production if necessary: what helped us was actually removing
useScreensmethod while using android platform for now.I’m seeing a similar error in the crash reports on google console for apps in production, maybe I should disable
enableScreens()on android. Here are my library versions:I’m using the
@react-navigation/stacknavigator, not the native stack navigator. I haven’t seen this error while testing, but it’s fairly common in my crash logs in production.My issue was the same, the app would work fine in development in an emulator, but when i built an APK and downloaded it onto the emulator, it crashed instantly.
This is because when creating my Stack to navigate, I was doing the following:
Instead, what I should’ve been importing was the following:
It’s a small error, and it didn’t break in local development for some reason, only in build
Sorry for the late reply, I was debugging the code and found out the issue was not with navigation but rather the image component, so had to replace that with a different library.
@kmagiera
could this be related to fix?
BTW. ToggleInspector works now as well! thanks for fix 😃
I hear from @adamczyk777 that this crash no longer occurs on the most recent release (2.0.0-beta.6). As I don’t see any repro case here I could use to verify I can only ask whoever reported the crash here if you still get it on beta.6. In case you do please comment below or start a new issue with a repro scenario.
+1
I’ve tried to start a new project from scratch, added react-navigation and all the dependencies, added stack and tabs, created a similar navigation setup but it doesn’t crash so I’ll need to slowly add more things until it breaks to pin down what’s causing this.