react-navigation icon indicating copy to clipboard operation
react-navigation copied to clipboard

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

Open PitlaSpandana opened this issue 6 years ago • 40 comments

am facing below error while upgrading from react-navigation 4 to 5:

Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager. This error is located at: in RNCSafeAreaProvider (at SafeAreaContext.tsx:74) in SafeAreaProvider (at SafeAreaProviderCompat.tsx:42) in SafeAreaProviderCompat (at StackView.tsx:453) in GestureHandlerRootView (at GestureHandlerRootView.android.js:31) in GestureHandlerRootView (at StackView.tsx:452) in StackView (at createStackNavigator.tsx:84) in StackNavigator (at createCompatNavigatorFactory.tsx:154) in Navigator (at AppContainer.js:75) in EnsureSingleNavigator (at BaseNavigationContainer.tsx:390) in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:91) in ThemeProvider (at NavigationContainer.tsx:90) in ForwardRef(NavigationContainer) (at AppContainer.js:74)


`package.json`

`"@react-native-community/masked-view": "^0.1.10",
    "react-native-gesture-handler": "^1.8.0",
    "@react-navigation/compat": "^5.2.8",
    "@react-navigation/native": "^5.7.6",
    "@react-navigation/stack": "^5.9.3",
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screens": "^2.0.0-beta.2",
`

`index.android.js`

`import 'react-native-gesture-handler';`

` render() {
    return (
      <AppContainer ref={container => (this.container = container)}>
        {this.state.showProgressIndicator ? this.renderProgressOverlay() : null}
      </AppContainer>
    );
  }`

appContainer.js

render(){ 
return(
 <View style={{ flex: 1 }}>
       {this.renderAlertModal()}
        <NavigationContainer>
<MainStackNavigator/>
        </NavigationContainer>
      </View>
);
}
mainstackNavigator.js

`const MainStack = createStackNavigator();
function MainStackNavigator() {
  return (
    <MainStack.Navigator
      headerMode="none"
      screenOptions={{
        header: null,
        headerShown: false
      }}>
      <MainStack.Screen name="home" component={homePage} />
    </MainStack.Navigator>
  );
}
export default MainStackNavigator;`

PitlaSpandana avatar Oct 20 '20 12:10 PitlaSpandana

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/compat (found: 5.2.8, latest: 5.3.0)
  • @react-navigation/native (found: 5.7.6, latest: 5.8.0)
  • @react-navigation/stack (found: 5.9.3, latest: 5.10.0)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

github-actions[bot] avatar Oct 27 '20 11:10 github-actions[bot]

I upgraded mentioned versions but still am getting same issue


Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager.
This error is located at:
 in RNCSafeAreaProvider (at SafeAreaContext.tsx:74)
 in SafeAreaProvider (at SafeAreaProviderCompat.tsx:42)
 in SafeAreaProviderCompat (at StackView.tsx:455)
 in GestureHandlerRootView (at GestureHandlerRootView.android.js:31)
 in GestureHandlerRootView (at StackView.tsx:454)
in StackView (at createStackNavigator.tsx:87)
in StackNavigator (at createCompatNavigatorFactory.tsx:158)
 in Navigator (at AppContainer.js:75)
in EnsureSingleNavigator (at BaseNavigationContainer.tsx:396)
in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:91)
in ThemeProvider (at NavigationContainer.tsx:90)
in ForwardRef(NavigationContainer) (at AppContainer.js:74)
in RCTView (at AppContainer.js:72)
`package.json`

`"@react-native-community/masked-view": "^0.1.10",
    "react-native-gesture-handler": "^1.8.0",
    "@react-navigation/compat": "^5.3.0",
    "@react-navigation/native": "^5.8.0",
    "@react-navigation/stack": "^5.10.0",
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screens": "^2.0.0-beta.2",
`

PitlaSpandana avatar Oct 27 '20 11:10 PitlaSpandana

did you ever figure this out?

joshmn avatar Oct 28 '20 21:10 joshmn

This is the first time I noticed the issue

PitlaSpandana avatar Oct 29 '20 04:10 PitlaSpandana

can any one please help me out on resolving this

PitlaSpandana avatar Nov 02 '20 04:11 PitlaSpandana

i get same error

suwu150 avatar Nov 04 '20 15:11 suwu150

You need to make sure that react-native-safe-area-context is linked properly. If automatic linking doesn't work, follow the documentation of the library to link it manually https://github.com/th3rdwave/react-native-safe-area-context#linking-in-react-native--060-1

satya164 avatar Nov 04 '20 15:11 satya164

I specified it manually, but I still haven't solved my problem

suwu150 avatar Nov 05 '20 08:11 suwu150

@suwu150 did you reinstall the pods again with pod install after upgrading the package?

rasidre avatar Nov 07 '20 06:11 rasidre

I specified it manually, but I still haven't solved my problem. and I reinstalled pods again and am running app in android

PitlaSpandana avatar Nov 09 '20 05:11 PitlaSpandana

facing the same issue, linking done and pod install done.

heypran avatar Dec 20 '20 10:12 heypran

Hey! Thanks for opening the issue. Seems that this issue issue related to react-native-safe-area-context library which is a dependency of React Navigation. Can you also post your issue in this repo so that it's notified to the maintainers of that library? This will help us fix the issue faster since it's upto the maintainers of that library to investigate it.

github-actions[bot] avatar Dec 21 '20 01:12 github-actions[bot]

For me stopping and re-running the app worked 😅

ankithans avatar Dec 25 '20 06:12 ankithans

For whatever reason, I receive this error when I run it through my detox tests. I don't get it when building it normally though.

Anyone else experience this with Detox?

quachdev avatar Dec 31 '20 18:12 quachdev

Follow These Steps:

I also got that error when setting up react navigations but the below code worked for me. Paste this code in the files shown below:

  • android/settings.gradle
include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')
  • android/app/build.gradle
dependencies {
    implementation project(':react-native-safe-area-context')
    ...
}
  • android/app/src/main/java/com/[APP_NAME]/MainApplication.java
import com.th3rdwave.safeareacontext.SafeAreaContextPackage;
  • android/app/src/main/java/com/[APP_NAME]/MainApplication.java (Add this code where the getPackages function exists)
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
        ...
        new MainReactPackage(),
        new SafeAreaContextPackage()
    );
}

OR if already a package is returned then this code

@Override
protected List<ReactPackage> getPackages() {
    List<ReactPackage> packages = new PackageList(this).getPackages();
    packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
    ...
    packages.add(new SafeAreaContextPackage());
    return packages;
}

You can also get this for IOS here

I was getting in android so I provided the android code.

sobhanbera avatar Jan 04 '21 17:01 sobhanbera

I got this issue. I cleaned cashes cd ios/ pod install and re-run the app works for me. I think react-native-safe-area-context was not properly installed.

Good luck 😉

aboux avatar Jan 07 '21 10:01 aboux

@SobhanBera : Great work! I got this exact error in a ReactXP project, when adding React Navigation to the React Native part of the project and trying to run it on a virtual device. After applying your changes, the project runs perfectly. How on earth did you find this out?

PiPauwels avatar Jan 29 '21 22:01 PiPauwels

@SobhanBera You are a life savior! My app works perfectly now, after applying your solution!

VelislavP avatar Jan 30 '21 09:01 VelislavP

For me running npm i [email protected] --save and then pod installing worked.

john-harding avatar Mar 13 '21 09:03 john-harding

I got this issue. I cleaned cashes cd ios/ pod install and re-run the app works for me. I think react-native-safe-area-context was not properly installed.

Good luck 😉

thanks, works for me

jobn123 avatar Mar 29 '21 09:03 jobn123