question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android app crashed when navigating from react fragment to native fragment

See original GitHub issue

Description

I have a closed repository in which I integrate React Native with Android Native. I put the react native component inside a fragment and use it for a bottom tab navigation screen. The bottom tab was made in native. So whenever I try to navigate after the react fragment is loaded, the app will crash. Navigation between tabs aside from the one with react fragment works fine.

I also put a react native screen in another place, not in a fragment because it’s not connected directly to the bottom tab navigation. That screen works fine and doesn’t cause any crash. So I assume the problem is within the fragment. I’m not too familiar with native android development so I was having a difficulty in this.

Steps To Reproduce

  1. The Main screen which has bottom tab navigation with react fragment on one of its tab
  2. Navigate to the tab with react fragment and load the rn component
  3. Click on other tabs, the app crashed

Expected behavior

Other native fragment will show according to clicked the bottom tab

Actual behavior

App crashed (only if the rn screen is loaded and navigate to other tab) Here’s the error

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: java.lang.IllegalStateException: FragmentManager is already executing transactions
        at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java:1778)
        at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1814)
        at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:303)
        at com.swmansion.rnscreens.ScreenContainer.removeMyFragments(ScreenContainer.kt:219)
        at com.swmansion.rnscreens.ScreenContainer.onDetachedFromWindow(ScreenContainer.kt:231)
        at com.swmansion.rnscreens.ScreenStack.onDetachedFromWindow(ScreenStack.kt:81)
        at android.view.View.dispatchDetachedFromWindow(View.java:19607)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3814)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5431)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5402)
        at android.view.ViewGroup.removeView(ViewGroup.java:5333)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1250)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:442)
        at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2169)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1992)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1947)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
        at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Package versions

  • React: 17.0.1
  • React Native: 0.64.0
  • React Native Screens: 3.7.2
  • React Navigation: 6.0.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
alexco2commented, Sep 28, 2021

@WoLewicki Thank you for checking! I thought since it just happens when using NativeStackNavigator from react-navigation, and the crash happening when navigating back, it might come from the same cause.

1reaction
alexco2commented, Sep 28, 2021

Could it be related to this bug? https://github.com/callstack/react-native-pager-view/issues/440 It only happens when using NativeStackNavigator, so I´m thinking it might be a react-native-screen issue. The error message is different though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >
Application crashes when navigating back to nested graph ...
In the example app included below I have a nested graph representing a setup workflow, ... IllegalArgumentException: Navigator androidx.navigation.fragment.
Read more >
android - App crashes when adding code into fragment activity
I'm new to android studio so I want to create an app that is using a navigation drawer to switch between 3 different...
Read more >
How to Resolve App Crashes in Android Studio?
Solutions to fix App Crash. 1. Observe the App Crash. Suppose you have built an application with multiple activities or fragments or both ......
Read more >
Fragments - React
<Columns /> would need to return multiple <td> elements in order for the rendered HTML to be valid. If a parent div was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found