itinance / itinance/react-native-fs

Installing react-native-fs causes app to crash. (Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.)

Open
#1,210 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

After installing the package and following the `Android usage` instructions, I get the following error message, when app is built and installed on AVD :
ERROR Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.
![image](https://github.com/itinance/react-native-fs/assets/29204301/9c750a42-1367-43df-8946-e78073dbc6dd)

Complete log :
```
Installing APK 'app-debug.apk' on 'Pixel_3a_API_34_extension_level_7_x86_64(AVD) - 14' for :app:debug

The Daemon will expire after the build after running out of JVM Metaspace.
The project memory settings are likely not configured or are configured to an insufficient value.
The daemon will restart for the next build, which may increase subsequent build times.
These settings can be adjusted by setting 'org.gradle.jvmargs' in 'gradle.properties'.
The currently configured max heap space is '2 GiB' and the configured max metaspace is '512 MiB'.
For more information on how to set these values, visit the user guide at https://docs.gradle.org/8.0.1/userguide/build_environment.html#configuring_jvm_memory
To disable this warning, set 'org.gradle.daemon.performance.disable-logging=true'.
Daemon will be stopped at the end of the build after running out of JVM Metaspace

> Task :app:installDebug
Installed on 1 device.
w: Detected multiple Kotlin daemon sessions at build\kotlin\sessions

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 31s
181 actionable tasks: 144 executed, 37 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.nova/.MainActivity }
BUNDLE ./index.js

ERROR [react-native-gesture-handler] react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).

For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation
LOG Running "nova" with {"rootTag":11}
ERROR Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.

This error is located at:
in RNSScreen
in Unknown (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by MaybeScreen)
in MaybeScreen (created by CardStack)
in RNSScreenContainer (created by ScreenContainer)
in ScreenContainer (created by MaybeScreenContainer)
in MaybeScreenContainer (created by CardStack)
in RCTView (created by View)
in View (created by Background)
in Background (created by CardStack)
in CardStack (created by HeaderShownContext)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by StackView)
in RNGestureHandlerRootView (created by GestureHandlerRootView)
in GestureHandlerRootView (created by StackView)
in StackView (created by StackNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by StackNavigator)
in StackNavigator (created by StackNavigator)
in StackNavigator (created by App)
in EnsureSingleNavigator
in BaseNavigationContainer
in ThemeProvider
in NavigationContainerInner (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in nova(RootComponent), js engine: hermes

ERROR TypeError: Cannot read property 'handleSetJSResponder' of null, js engine: hermes
```

`package.json`:
```json
{
"name": "whatever",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.19.4",
"@react-navigation/native": "^6.1.9",
"@react-navigation/stack": "^6.3.20",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-blob-util": "^0.19.2",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.13.4",
"react-native-image-picker": "^7.0.2",
"react-native-safe-area-context": "^4.7.4",
"react-native-screens": "^3.27.0",
"react-native-vector-icons": "^10.0.1",
"zustand": "^4.4.4"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/react": "^18.0.24",
"@types/react-native-vector-icons": "^6.4.16",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.76.8",
"prettier": "^2.4.1",
"react-test-renderer": "18.2.0",
"typescript": "4.8.4"
},
"engines": {
"node": ">=16"
}
}

```

`MainApplication.java`:
```java
package com.nova;

import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import com.facebook.react.shell.MainReactPackage;
import com.rnfs.RNFSPackage;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RNFSPackage());
}

@Override
protected String getJSMainModuleName() {
return "index";
}

@Override
protected boolean isNewArchEnabled() {
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}

@Override
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for
// this app.
DefaultNewArchitectureEntryPoint.load();
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
}
```

If i remove the `react-native-fs` package, and reverse the changes in `android` folder, the project works with no error.

developing on `windows 11`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.