🎃

[react-native] “RNCSafeAreaProvider” was not found in the UIManager

2024/03/21に公開

状況

running npx react-native android
I get the following error:

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

error

解決方法

Workaround Solution:

  1. Adding this to dependencies in "/android/app/build.gradle"
dependencies {
    implementation project(':react-native-screens')
}
  1. Adding this to protected List<ReactPackage> getPackages() in "/android/app/src/main/java/com/[my-app-company]/[my-app]/MainApplication.java"
    @Override
    protected List<ReactPackage> getPackages() {
     @SuppressWarnings("UnnecessaryLocalVariable")
     List<ReactPackage> packages = new PackageList(this).getPackages();
        packages.add(new com.swmansion.rnscreens.RNScreensPackage());
        packages.add(new LinearGradientPackage());
    return packages;
    }
  1. Then Finally Adding this to "/android/settings.gradle"
include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')
  1. Run the ./gradlew clean Gradle task on the command line

  2. And run simulator again via npx react-native android

Discussion