Closed paulmelnikow closed 3 years ago
Any Solution?
react-native link react-native-sound cd ios pod install
fixed my problem
None of these fixed the issue in IOS at RN 0.60.4, also manual linking is not working at all.. So what to do?
@losheredos You can open a new issue and fill out the template, and hopefully someone can help you troubleshoot.
@BenjaminLiCN i found this worked after I ran XCode -> clean build folder and then pod install
react-native link react-native-sound not work use react-native 0.61.2
pod install did not solve my problem react-native 0.61.2
linking and pod installing solved this issue in 61.2 for me in both android and ios
https://stackoverflow.com/questions/57698661/undefined-is-not-an-object-evaluating-rnsound-isandroid
If I get it right, I can never get this to work when my App is made with Expo? I am new to React-native and just did buy a course to learn and wanted to try to implement react-native-sound and keep getting this error. My package.json looks like this: { "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "eject": "expo eject" }, "dependencies": { "expo": "^33.0.0", "pod": "^0.9.0", "react": "16.8.3", "react-dom": "^16.8.6", "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz", "react-native-sound": "^0.11.0", "react-native-web": "^0.11.4", "react-navigation": "^3.11.0" }, "devDependencies": { "babel-preset-expo": "^5.1.1" }, "private": true }
Edit: I guess I have to use this then? https://docs.expo.io/versions/latest/sdk/audio/
Edit 2: That seems to be it. You can't use native modules with Expo unless you want to work around it: https://docs.expo.io/versions/latest/expokit/eject/
*I will just leave this here in case it helps other people. I am probably not the only beginner trying to do this. Feel free to delete it if this does not belong here :)
@VictorVermeulen correct. It's not possible to use any module not supported by Expo when you're using expo, so your issue does not really belong here, and is a natural cause. So yes, if you're using Expo, you need to use the expo-av library (which is very unstable afaik..).
Anyway.
I'm getting this error on Android (not iOS) after linking. I've checked the manual linking steps as well, but it looks right to me (except the manual steps say compile
while all other lines in my RN project say implementation
so I'm assuming that the instructions are old..?
Here are screenshots from the changes applied in my project after linking (not displaying iOS here since it works there):
I just set up a brand new project using react-native init
followed by yarn install react-native-sound
and react-native link react-native-sound
and got these changes after linking:
---
android/app/build.gradle | 1 +
android/app/src/main/java/com/soundtest/MainApplication.java | 1 +
android/settings.gradle | 2 ++
ios/Podfile | 2 ++
4 files changed, 6 insertions(+)
diff --git a/android/app/build.gradle b/android/app/build.gradle
index ee614be..23490f4 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -179,6 +179,7 @@ android {
}
dependencies {
+ implementation project(':react-native-sound')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
diff --git a/android/app/src/main/java/com/soundtest/MainApplication.java b/android/app/src/main/java/com/soundtest/MainApplication.java
index 4af8585..34d32ee 100644
--- a/android/app/src/main/java/com/soundtest/MainApplication.java
+++ b/android/app/src/main/java/com/soundtest/MainApplication.java
@@ -4,6 +4,7 @@ import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
+import com.zmxv.RNSound.RNSoundPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
diff --git a/android/settings.gradle b/android/settings.gradle
index d73c393..6a32120 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,3 +1,5 @@
rootProject.name = 'soundtest'
+include ':react-native-sound'
+project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
diff --git a/ios/Podfile b/ios/Podfile
index 48dec66..5afea82 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -34,6 +34,8 @@ target 'soundtest' do
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
+ pod 'RNSound', :path => '../node_modules/react-native-sound'
+
target 'soundtestTests' do
inherit! :search_paths
# Pods for testing
--
As you can see, one change is missing here, namely new RNSoundPackage(),
in MainApplication.java,.
I eventually got past this error, but I have no idea how. Probably a combination of rebuilding node_modules, removing old builds, running ./gradlew cleanBuildCache
etc.
I had this issue when working with Android Studio and got past it, although my mistake was a pretty amateur one (note that this will be Android Studio specific). In the documentation, the React developers mention that you need to run both
$npx react-native start
and
$npx react-native run-android
to get the app running on your emulator. Well, the second command threw an error for me ("missing tool.jar" - that was a whole other nightmare to figure out), and there is a typo in the documentation that I found confusing. Since I could get my app to show up in the emulator while just running the first command, however, I continued only doing that. Turns out that the "react-native link react-native-sound" CLI command will not link this and other libraries properly if you don't actually run the second command. After managing to run "npx react-native run-android" without errors, I tried the "react-native link react-native-sound" command and it worked.
Beginner's mistake, but hopefully I will save somebody else some time by putting it here.
When I run "npx react-native run-android" Still facing the issue for android "undefined is not an object (evaluating 'RNSound.IsAndroid')". Anyone got the solution to resolve it. Please reply need urgently.
I fixed by performing the following
react-native link react-native-sound
cd android && ./gradlew cleanBuildCache
npm run start
or whatevernpm run android
or whatever.In my case, I am able to solve this error, by re-linking the libraries react-native link
(not only the react-native-sound) and installing the app npm run android
again.
on Android Emulator:
"react": "16.13.1",
"react-native": "0.63.1",
"react-native-sound": "^0.11.0",
Fixed this bug on react-native 0.61.5: add in Podfile _pod 'RNSound', :path => '../nodemodules/react-native-sound' pod install
RN 0.63.*
yarn
cd ios && pod install
Then you must close and re-compile app. Simply running yarn and pod install will cause OP's error.
https://stackoverflow.com/questions/57698661/undefined-is-not-an-object-evaluating-rnsound-isandroid
If I get it right, I can never get this to work when my App is made with Expo? I am new to React-native and just did buy a course to learn and wanted to try to implement react-native-sound and keep getting this error. My package.json looks like this:
{ "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "eject": "expo eject" }, "dependencies": { "expo": "^33.0.0", "pod": "^0.9.0", "react": "16.8.3", "react-dom": "^16.8.6", "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz", "react-native-sound": "^0.11.0", "react-native-web": "^0.11.4", "react-navigation": "^3.11.0" }, "devDependencies": { "babel-preset-expo": "^5.1.1" }, "private": true }
Edit: I guess I have to use this then? https://docs.expo.io/versions/latest/sdk/audio/
Edit 2: That seems to be it. You can't use native modules with Expo unless you want to work around it: https://docs.expo.io/versions/latest/expokit/eject/
*I will just leave this here in case it helps other people. I am probably not the only beginner trying to do this. Feel free to delete it if this does not belong here :)
I use this function successfully sovled my problem. anyone who use Expo can try this way.
The most common problem developers experience with this library is
undefined is not an object (evaluating 'RNSound.IsAndroid')
.This is caused by the library's native code not being linked. This is a tooling issue and seems to have a variety of different specific resolutions, depending on your environment.
See these related threads:
36 (48 comments)
215 (30 comments)
128 (16 comments)
471 (14 comments)
If you're experiencing this issue and want help troubleshooting it, please review those threads first. If you aren't able to resolve the problem, please open a new issue with a link to a project that reproduces the project, information about your environment, and information about the steps you have tried.
Meanwhile, it would be very helpful if someone could collect the troubleshooting advice from those sources, and write it up in the readme.
Note, also reported here:
57
352
446
541
567