🎃
[react-native] “RNCSafeAreaProvider” was not found in the UIManager
状況
running npx react-native android
I get the following error:
ERROR Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager.
解決方法
Workaround Solution:
- Adding this to dependencies in "/android/app/build.gradle"
dependencies {
implementation project(':react-native-screens')
}
- 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;
}
- 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')
-
Run the
./gradlew clean
Gradle task on the command line -
And run simulator again via
npx react-native android
Discussion