undefined is not an object (evaluating 'RNSound.IsAndroid') - react-native

I am trying to get react-native-sound to work on my react-native app but I keep getting this error: undefined is not an object (evaluating 'RNSound.IsAndroid').
I have noticed that any people have received this error and I found a relevant question already on here, but I am super noobie and don't understand most of the solutions people have suggested.
I have tried react-native link react-native-sound, but it did not change anything. From reading people's comments I must now manually Install, but I don't really understand what I am doing. Even step one... go to android/app/src/main/java/.../MainApplication.java. I don't understand this as I can't see an android file anywhere. I am using Visual Studio (windows 10) and expo cli with my own Pixel 2 plugged in (hence I am not using Android Studio).
Any help would be fantastic.

We can't use native modules with projects which is created by expo cli.
So, either you can use alternative package for expo which is https://docs.expo.io/versions/latest/sdk/audio/
or if you are familiar with native development, you can eject your project from expo to use native android/ios project with react-native cli.

Related

React Native Error - TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNShare.FACEBOOK')

I'm working on react native project and I am using expo. I want to add the react-native-share package to my project, however I keep getting this error before I even add any code.
TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNShare.FACEBOOK')
Now I know that expo has it's own version of the share, however you can't specify where a person can share it too, which honestly makes the feature useless. It seems to be clear that the reason I can't use this package is because I am using expo and can't install pod into the project -- due to expo reject it --. So what should I do? Any suggestions on how to work around this?
You can't normally use dependencies with native code using Expo. At least when using the classic build system (you're using it when you run expo start in the terminal to run your project). react-native-share has native code (you can check that by going to the repo and seeing if the library has ios and android folders) and therefore can't be used with "standard" Expo.
If you want to use custom native code in your project, you either need to eject from Expo to the bare workflow or - a newer option - use Expo EAS and custom dev clients. Expo EAS allows you to stay in the managed workflow and still use native modules. You might need to write something called a config plugin for some of those native dependencies you want to use, but looking at the documentation, react-native-share should be working just fine without a config plugin.
So: Either eject to the Expo bare workflow, or use Expo EAS and custom dev clients to use native dependencies with the Expo managed workflow. Do note however that you need at least Expo SDK 41 to use EAS and custom development clients.
To learn more about migrating from the classic build system to EAS, see Expo's guide / documentation.

I can't use any library that uses linking in an ejected bare expo project

I ejected my project a few days ago to use so components in Android that weren't available for expo projects like a background module that can handle notifications but I can't use a single one. I tried the react-native-background-job, react-native-background-fetch, react-native-background-task but all gave a similar error message:
[Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNBackgroundFetch.configure')]
Where 'evaluating X' had different X for each module. I tried checking if I missed any installation steps but I couldn't find anything wrong and since it's for many modules I guess it's a from a common cause which I can't solve individually. Thanks in advance for the attention
I figured it out. Expo can't run the libraries that require linking even when ejected. For that you have to use
react-native start
in it's own terminal window to start the metro and
npx react-native run-android
In a separate window

Why is that we cannot install native libraries on Expo? (that requires linking)

I am a newbie and learned react-native expo. I am curious why we can't use any native library with Expo.
For example, if I want to use filesystem on expo I just cant use it, I know expo has it's own file system but I want to use another library but that library requires linking so it is not working in expo. Why is that?
I have tried everything.
This is the library that I want to use ==> https://github.com/itinance/react-native-fs
It requires command : react-native link react-native-fs
How do I do it?
You first have to understand the difference between react-native cli & expo
Please read this documentation to understand the difference
React Native expo uses their own servers to compile your javascript into java and return APK file as a complete APP, and that is the reason you do not need android SDKs or android studio environment on your PC when you are using expo
but when you are using react-native cli you do need the android studio environment such as SDKs, because when you are using cli , it compiles the code using that android studio sdk/environment that you made in your PC that is why you do not need a third party server like expo do.
and thats the reason you get android files right in your react-native project and due to which you can add native modules to it.
However you also have the option to use expo-eject, You can read more about expo-eject in this documentation
Thank You!, Have a great day & welcome to stackoverflow community!.

How to create react-native app for route like uber, with the use of HERE-MAP?

installed 'npm install react-native-heremaps --save'
This is for react-native init android, I tried some application using ios concept.
Error
Loading dependency graph, done. Error: Unable to resolve module ./index
Referrence:
Github ios sample
this question is a bit vague for SO, something that would require an entire course to answer. Currently it looks like you should learn how to do react-native android before attempting to add on top HERE. There are many great tutorials to get that started and working.
For the here portion you will have to use the Here-Maps-SDK. Since there isn't a react version of this SDK, you will need to link it using a react bridge.
It's not that easy of a process, and will take a decent amount of work to get right.
Here are some examples to help get started: https://hackernoon.com/react-native-bridge-for-ios-and-android-43feb9712fcb
https://facebook.github.io/react-native/docs/native-modules-ios

React-Native-Video does not work with create-react-native-app?

I have a react-native project that I created using create-react-native-app. I would like to play videos in this app. I tried react-native-video but it gave me the error
TypeError: undefined is not an object (evaluating '_reactNative.NativeModules.UIManager.RCTVideo.Constants')
I then tried using react-native-video-controls and it created the same error.
Other solutions seem to revolve around calling react-native link, but this doesn't work for a create-react-native-app app. Am I out of luck using react-native-video or is there another solution to avoiding this error?
create-react-native-app builds a react native app using Expo. When using expo I believe you can't bring in native modules, only use what they provide. So anything that tells you to do react-native-link won't work.
Using react-native-init will build you a bare react-native project in which you will be able to bring in native modules.
However expo does provide a video api you can use: https://docs.expo.io/versions/latest/sdk/video.html