2

When I run the React Native app using the Expo Go app on iOS, it runs without problems, but when I run it using the Expo Go app on Android, an error occurs.

    Invariant Violation: requireNativeComponent: "RNSScreenNavigationContainer" was not found in the UIManager.
    This error is located at:
    in RNSScreenNavigationContainer (created by ScreenContainer)
    in ScreenContainer (created by MaybeScreenContainer)
    in MaybeScreenContainer (created by DrawerView)
    in RCTView (created by View)
    in View (created by DrawerView)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by DrawerView)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by PanGestureHandler)
    in PanGestureHandler (created by PanGestureHandler)
    in PanGestureHandler (created by DrawerView)
    in DrawerView (created by DrawerViewBase)
    in DrawerViewBase (created by DrawerView)
    in RNGestureHandlerRootView (created by GestureHandlerRootView)
    in GestureHandlerRootView (created by DrawerView)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by SafeAreaInsetsContext)
    in SafeAreaProviderCompat (created by DrawerView)
    in DrawerView (created by DrawerNavigator)
    in PreventRemoveProvider (created by NavigationContent)
    in NavigationContent
    in Unknown (created by DrawerNavigator)
    in DrawerNavigator (created by App)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by App)
    in App (created by withDevTools(App))
    in withDevTools(App)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent), js engine: hermes
    at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in reportException
    at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in handleException
    - ... 7 more stack frames from framework internals

I deleted and installed the react-native-screens app, and deleted and reinstalled the node_modules directory and yarn.lock.

mth2171
  • 21
  • 2

1 Answers1

0

Just check all necessary steps are done for the setup library, after that runs your code from the native platform android studio or Xcode.

If the above thing doesn't work for you, delete the node-modules and pods folders. After that run the below code

npm install or yarn install
cd ios 
pod install

now run again from the native platform.

Android native changes:

On Android the View state is not persisted consistently across Activity restarts, which can lead to crashes in those cases. It is recommended to override the native Android method called on Activity restarts in your main Activity, to avoid these crashes.

For most people using an app built from the react-native template, that means editing MainActivity.java, likely located in android/app/src/main/java//MainActivity.java

You should add this code, which specifically discards any Activity state persisted during the Activity restart process, to avoid inconsistencies that lead to crashes. Please note that the override code should not be placed inside MainActivityDelegate, but rather directly in MainActivity.

import android.os.Bundle;

public class MainActivity extends ReactActivity {

//...code

//react-native-screens override
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
}

public static class MainActivityDelegate extends ReactActivityDelegate {
    //...code
}
}
Jatin Bhuva
  • 1,301
  • 1
  • 4
  • 22
  • First of all, thank you for your reply. I'm sorry for the late comment, but after opening the project from scratch, I found that the error does not occur in a specific code, but after installing mediapipe/pose to use tensorflow, the same error occurs. – mth2171 May 03 '23 at 18:39
  • No, I haven't solved it yet. To use react native navigation, I must install the react-native-screens package, and to recognize motion using tensorflowjs, I must use mediapipe/pose. I keep searching for errors, but I don't know the solution. – mth2171 May 05 '23 at 09:45
  • Yes, so I was talking about native changes for react-native-screens library. Have you done that? see I have updated above answer – Jatin Bhuva May 05 '23 at 12:50
  • It was already applied to my code. And I haven't solved it yet. – mth2171 May 07 '23 at 15:49