Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager

Viewed 67229
26 Answers

Faced the same issue while implementing Navigation. Run following commands

npm install @react-navigation/native

React Navigation is made up of some core utilities and those are then used by navigators to create the navigation structure in your app.


In your project directory, run:

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

This will install versions of these libraries that are compatible.

If you're on a Mac and developing for iOS, you need to install the pods to complete the linking.

npx pod-install ios

Now run


react-native run-ios

I think you are missing to install react-native-screens components. That is required part in install react navigation guideline.

Dont forget to run pod install in ios folder after install package from npm.

stop all the terminal servers and then run

npx react-native run-android

if it still does not work,

npm i react-native-screens

and then

npx react-native run-android

That usually happens when you install all packages to add navigation without terminating the running build. Make sure to stop the running process for ( android or IOS ) then run it again after installing them and adding the routing components

Close Metro and run npx run android to rebuild your code

This solution (source) always works for me, here is the exact solution:

If you're facing with this error

Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.

Follow these steps:

1. Make sure in your `package.json` file if you have the following packages:

  • @react-native-community/masked-view
  • @react-navigation/native
  • @react-navigation/stack
  • react-native-gesture-handler
  • react-native-reanimated
  • react-native-safe-area-context
  • react-native-screens

2. Next ensure if you have pods up-to-date (For iOS only) by making sure cd ios --> pod install --> cd ..

3. And finally cancel the current build by pressing Ctrl+C (twice/thrice) and then do npx react-native run-ios

RNSSCreens error because the react-native-screens isn't installed on the your project

just run npm install react-native-screens react-native-safe-area-context or if your using yarn run 'yarn add install react-native-screens react-native-safe-area-context'

Hey i was also facing same problem . Just use

npm install react-native-screens

.

This helped me. install this package

npm i react-native-screens

and add

import { enableScreens } from 'react-native-screens';

enableScreens();

I've encountered the same problem, and solved it.

You can just close the terminal and app on Android Emulator(or device), and just run npm run android or react-native run-android again.

I think they might have some cache and occur the error.

I hope you can fix the problem.

  1. Close the Metro and IOS simulator.
  2. Ensure you go to your ios folder run pod install
  3. Reopen your simulator

This should solve the problem. I also use quite a while to figure it out

I worked on this problem for several days and this is want worked for me:

In the android\app\src\main\java(your project name)\MainApplication.java

add to Imports:

import com.swmansion.rnscreens.RNScreensPackage;

Then add new RNScreensPackage() to the ReactPackage List:

@Override
    protected List<ReactPackage> getPackages() {       
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),  
            ...
            new RNScreensPackage()
      );
    }

Edit: This was after I tried everything else here.

As I don't have enough reputations to upVote the answer, I am mentioning the answer which worked out to me here Solution mentioned by @Gurjinder Singh , worked smoothly..

Recapturing:

Issue : With Expo, Sanity.io app was working on device in dev, but once apk was generated using "eas build -p android --profile preview" , build was successful but when I tried opening the app in my mobile, after splash screen app was crashing.

Adblogcat showed : com.facebook.react.common.JavascriptException: Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.

Solution worked:

npm install @react-navigation/native

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

thanks to community and @Gurjinder Singh (top voted)

You go into the ios folder of your project folder and run the following command.

pod install

Then run the simulator.

You must have react-native-screens installed and I'm guessing that you have done it. So, I will just you a Problem that maybe is not really clear in the documentation.

So you probably just Install React Navigation on your app.

Once you installed it, you need to restart you app.

So close your app, run react-native run-ios or react-native run-android again.

React navigation Install some native modules. Thus, you need to restart that app as I mention.

This is really clear on their documentation.

I also came across the same problem. For Android, I uninstall the app from the emulator then build the app again.Problem solved. Assuming that you already installed packages you need.

Just stop running your node server and build the app again from Xcode/Android Studio or using command react-native run-ios or react-native run-android

In case you are on android, you need to rebuild using npx run android or react-native run-android The new installed apk will work fine

In my case, the following code block helped!

npm install react-native-screens
npm run android/ ios

I also get this error and after doing these steps my app starting running

  1. cd android
  2. ./gradlew clean (for windows or linux)
  3. npm install react-native-screen
  4. react-native start & react-native run-android

worked for me yarn add react-native-reanimated

"@react-navigation/native": "^6.0.10", "@react-navigation/native-stack": "^6.6.2", "react": "17.0.2", "react-native": "0.68.2", "react-native-reanimated": "^2.8.0", "react-native-safe-area-context": "^4.3.1", "react-native-screens": "^3.13.1", "styled-components": "^5.3.5"

Finally found the solutions, first by creating new project and secondly re-setup of the react-google-maps library.

Workaround Solution: Created new project, installed all dependencies from scratch, followed step-by-step installation guidelines of react-native screens, and finally moved all my code files into a newly created project. This worked for me :D

After digging into the project code and compared project code with newly generated code, here are my findings:

Actual Problem: We had integrated react-native-google-maps library some time ago, for which I and other developers followed step-by-step guidelines and made changes in the MainActivity.java file in the android folder. There were some misconfigurations due to which RNSScreen issue was getting thrown.

Actual Solution Removed react-native-google-maps completely (uninstalled npm packages) and removed Google Maps configuration and did set up the react-google-maps library again

In conclusion, if any of the developers, try to set up google maps in react native, please check the version of react native and react-native-google-maps library and then follow the steps carefully.

Hopefully, this would answer your queries.

(It Workes For Me..!)

for React-native developers.. Some times the changes of packages Not reflacted in xcode so follow this steps for Solution..

Open Project in xcode -> Clean Buid Folder -> (Rebuid Your Project)Run on any Simulator and wait for Build.. ->Once Build either You can run again by Terminal or continue work by xcode..

none of the recommended answers worked until I tried what I found in this comment plus restart my steps:

  • deleting the node_modules directory
  • turn Metro and actually quit the simulator completely
  • yarn to install again
  • start metro via npx react-native start
  • install pods via npx pod-install ios
  • run simulator again via npx react-native run-ios

Make sure the below plugin install and linked with android & ios?

npm install react-native-screens

If not linked then perform the below command

react-native link react-native-screens

after successfully linked for android and ios, "Sync Gradle" from android studio and "pod install" for ios

Now close the terminal and again build and run app

I updated Expo to 45.0.0. That fixed the error and solved a problem with the app crashing after launch in production mode but working fine on device with QR code or simulator.

Related