Sendbird SDK requires fs package in react native - react-native

When I install the sendbird SDK into a expo managed react native project I get the following error:
The package at "node_modules/sendbird/SendBird.min.js" attempted to import the Node standard library module "fs". It failed because React Native does not include the Node standard library. Read more at https://docs.expo.io/versions/latest/introduction/faq/#can-i-use-nodejs-packages-with-expo
However fs is a node package which isn't the environment run by react native. I've looked through the Sendbird examples, and have used this very same SDK in other apps. What am I doing wrong with this one?

SendBird here! Our apologies, but there is a known issue in JavaScript version 3.0.119 that is causing it. This will be fixed in the next version, coming very soon! In the meantime, please build with version 3.0.118 as needed.
If you are using npm, you can run this command:
npm install --save sendbird#3.0.118

Related

Unable to resolve module #react-native-masked-view/masked-view 2021

I have already tried all of the answers in this previous thread and they have not worked
Unable to resolve "#react-native-community/masked-view
I have been unable to build my app in any capacity. Using expo ~42.0.0 to manage installations.
Unable to resolve module #react-native-masked-view/masked-view from
/node_modules/#react-navigation/elements/src/MaskedViewNative.tsx
Here is that file on their main branch
https://github.com/react-navigation/react-navigation/blob/main/packages/elements/src/MaskedViewNative.tsx
Just curious what this error means, expo documentation says react navigation uses #react-native-community/masked-view this error and code in the latest release says other wise
https://docs.expo.dev/versions/latest/sdk/masked-view/
Has anyone found a solution?
expo documentation says react navigation uses #react-native-community/masked-view
Expo documentation says React Navigation 5.x uses #react-native-community/masked-view. You're probably using React Navigation 6.x, not React Navigation 5.x. But it doesn't matter what Expo documentation says if you're getting an error because a specific package is missing and you already know which package it is.
You need to install #react-native-masked-view/masked-view:
expo install #react-native-masked-view/masked-view

Using highcarts in react native and getting the error

I have installed npm install #highcharts/highcharts-react-native in my react native project and i also added the hcscript in metro.config.js file.
Iam getting the error of
Failed to fetch scripts or layout. The method or property expo-file-system.readDirectoryAsync is not available on android, are you sure you've linked all the native dependencies properly?
if you wanted to use this package: #highcharts/highcharts-react-native you should first install react-native-unimodules which is a set of native dependencies used at the core of #highcharts/highcharts-react-native as
they built the package on top of expo not bare react native.
it is going to require you to make heavy edits in the native ios and android files such as appDelegate.m in ios and more alike files.
However, you should notice this package is deprecated as per the official page, and there is no reliable alternative!

How to link native library to react native application and what is the folder structure?

I am trying to build simple app to creative native library and link with react native app.
I am facing issue like
Error : Unable to resolve module react-native-fingerprint from App.js: react-native-fingerprint could not be found within the project.
Note : 'react-native-fingerprint' which is been created and want to link with app.
I guess you're using react-native-fingerprint-scanner. Since library you mentioned doesn't exist.
In case if you using this library react-native-fingerprint-scanner.
Installation
npm install react-native-fingerprint-scanner --save
or
yarn add react-native-fingerprint-scanner
Link to Native Platforms
react-native link react-native-fingerprint-scanner
Even after this it is not working. Following this guide

react-native-image-picker installation breaks my app

Step 1: npm install react-native-image-picker
......app is still building fine.....
Step 2: react-native link react-native-image picker
...app no longer compiles
When I clean gradle I get error:
"Could not set process working directory to 'C:\code\rn\xs\node_modules\react-native-image-picker\example\android': could not set current directory (errno 3)"
When I try to rebuild in gradle I also get error:
"Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-117 to override".
So I take suggestion of error message and add 'tools:replace="android:appComponentFactory"' to application element.....
I now still get same error when I clean.....but error when I rebuild is a little different:
"tools:replace specified at line:10 for attribute android:appComponentFactory, but no new value specified.".
Please help!!
As addition for Lenoarod answer, you can use jetifier library. It will help you to convert all library that hasn't converted to AndroidX.
According to it's documentation
So now you need to convert your app to AndroidX, but many of your react-native libraries ship native Java code and have not updated. How is this done?
First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
1. npm install --save-dev jetifier
2. npx jetify
3. npx react-native run-android (your app should correctly compile and work)
4. Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)
your react-native version uses Androix library, but the react-native-image-picker which you installed used android.support.v4. So when you build the project, that error happens. there two ways for this solution Which I suggest.
the one solution is that you update your react-native-image-picker version. the new version supports the androix supported library. the following is the official
guide
To use this library you need to ensure you match up with the correct version of React Native you are using. the flowing is the [official guide][1].
p.s. React Native introduced AndroidX support in 0.60, which is a breaking change for most libraries (incl. this one) using native Android functionality.
If you have to use the old version, you can modify the react-native-image-picker related files. for example the ImagePickerModule,ImageConfig. they locate in android/src/main folder
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
Thanks both.
lzzuddiin's answer was closest....all I needed to do was "Refactor > Migrate to AndroidX" from the menu bar; that alone solved the issue

React Native Video

i'm trying to use 'react-native-video' in my application, i have used the following lines to get it:
npm install --save react-native-video
react-native link react-native-video (since my react native version is 0.59)
after doing so and using "Video" component from 'react-native-vide' i got an error like below:
what is the problem? what can i do? any ideas?
You did not link the library properly.
After having installed the library through npm i --save react-native-video, you'll need to run react-native link react-native-video in order to link it. This may or may not work - if it does not, you'll need to link manually according to the installation instructions of the library.
You might be using CocoaPods in which case you'll need to run these commands as well: cd ios && pod install
If you receive an error, you're most likely not using CocoaPods and this is the wrong approach.
Please note that you'll need to reinstall the app on the phone / simulator afterwards since you've changed the native dependencies. You'll also need to do this if you're using (ejected) Expo or anything alike. If you're using Expo with the managed workflow (= not ejected) you're not able to use libraries that depend on native linking.