-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Troubleshooting "undefined is not an object (evaluating 'RNSound.IsAndroid')" #592
Comments
This comment has been minimized.
This comment has been minimized.
react-native link react-native-sound 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 |
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: 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 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 ---
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 |
I eventually got past this error, but I have no idea how. Probably a combination of rebuilding node_modules, removing old builds, running |
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" |
I fixed by performing the following
|
In my case, I am able to solve this error, by re-linking the libraries on Android Emulator: |
Fixed this bug on react-native 0.61.5: |
RN 0.63.*
Then you must close and re-compile app. Simply running yarn and pod install will cause OP's error. |
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:
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:
The text was updated successfully, but these errors were encountered: