-
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
Not working on IOS: Cannot read property 'IsAndroid' of undefined #36
Comments
Are you on the latest version? Are you seeing the issue with https://github.com/zmxv/react-native-sound-demo ? |
Yes, I am on the latest version. I will clone from the link you provided and get back to you asap. |
I am unable to run the demo project because I get the following error: Add RNCookieManagerIOS.h and RNCookieManagerIOS.m to your Xcode project despite running |
Weird. Neither the demo app nor the native module directly depends on RNCookieManager |
The error is this line: |
This error seems to have nothing to do with the sound module. |
Back to the original issue, do you have any idea what's causing it? |
FYI, I am able to successfully run the demo project. Digging the sample audio. |
Having the same issue, any updates @Frosty92? |
Unfortunately no. |
I'm unable to reproduce the issue with the demo app. |
I had this error as well when adding the dependencies but forgetting to recompile. After a new build it worked like a charm! cc @Frosty92 |
Mine was solved after reintalling node modules and recompiling - haven't had the issue since (touch wood) |
I have the same issue, and I tried reinstalling node module and recompiling, but it didn't help. is this what you did? @will-ockmore |
Stack trace is:
Once I reload the page, it just shows one line
|
I finally resolved this issue by following steps (I don't know which one fixed the issue, so I'll put everything I did)
Now I see |
I am getting this issue on Android but not iOS after updating react native to version 0.31 RNSound is undefined. I suspect it may have something to do with rnpm link. As the result of rnpm link seems to be different to the manual installation instructions for Android. Having said that I couldn't get it to compile at all using the manual instructions |
I get
probably related. import issue. After reading Sound.js it was an easy fix:
|
Deleting all files in iOS build folder and restarting the packager solved the issue
|
@RinorDreshaj there is no such folder as far as I can see. where do you find it? |
I have got the same issue with Android undefined is not an object (evaluating 'RNSound.IsAndroid') |
Luckily, I fixed by rebuild android and react-native run-android. Thanks all |
@anhtata Please help me i am also facing issue in android. I tried
but still same issue |
@snsekar @Frosty92 @zmxv @will-ockmore @Roconda @sydneyitguy Had the same issue on iOS & Android and was able to fix it. iOS: My fault I did not choose my target correctly i.e. under built target I had Android: According to RN docs I am using RN version 0.39.2. Hope this helps. |
Looks like there is a Pull Request already on this issue. |
I was able to fix the issue What I did was just to reinstall react-native-sound Just for reference, to play a sound just open xcode, and drag-drop your sound file into the root of the xcode project library:
Then tick Copy items if needed, Create folder references and in add to targets select your AppName, then click finish to add it to your project. Now go to your Project Build Phases and make sure your sound file is listed on Copy Bundle Resources, if it's not in there, add it by drag-drop your sound file. Now everything should be ready, just don't forget to run your app in xcode to build it. Here's a sample code I'm using in my React Native app:
And now it's 100% working, I tried it on iOS only, but the original error should be gone on both platforms. Just don't forget to run the project with xcode, then you can use Hope this is helpful! 😊 |
Interesting - it's possible the differences between |
I had this issue on iOS briefly, just after running I fixed it by recompiling. I forgot to do that 🙈. This is probably not the same issue as what others are experiencing though. |
I'm closing this as folks have posted helpful solutions that seem to work for people |
none of the suggested solutions worked for me, running |
@benvium I'm not sure why would you close an issue and I'm seeing tone of people encountering this error? |
@DeanKamali Which version of the react-native cli and react native are you using? react-native link worked for me (no manual steps required) on React Native 0.41.2, cli version 1.3.0, Xcode 8.2.1. |
I'm using newer react-native-cli
|
@DeanKamali ok. I just tried:
... and for me it linked the library correctly. What happens when you try? |
@benvium I followed your steps verbatim and created new project and I can confirm that Thanks for taking the time to check it out. |
@DeanKamali No problem. I'll re-close this ticket until the issue crops up again :-) |
Had the same experience as @DeanKamali - |
I solved this problem. |
I have been unable to resolve the problem following any of the above steps. I am using create-react-native-app. Has anyone had found a solution to using create-react-native-app? |
I believe your problem is unrelated. create-react-native-app creates an expo app, and that means it does not work the same when it comes to native modules. you might have to do something called "eject" but this is not just a tiny step, you really should learn more about what it means to have an expo app. |
You need to delete your derived data in XCode: |
I'm able to solve this error, by re-linking the libraries again react-native link
react-native run-ios |
I am hating myself because I frantically scrolled through the github comments looking for a solution but only after 25 minutes did I realize that I forgot to run |
I only get the error when running unit tests! |
Linking doesn't work whether i relink the library or not, manual installation doesn't work either. Build on ios, both debug and release tested. ps : fixed this by doing a pod install after linking the library. Now i got to get it to work. |
In my case, I used: npm i --save react-native-sound and then react-native link react-native-sound But then I found under /node_modules/react-native-sound/, there is no 'android' folder. So I downloaded 'react-native-sound' manually, copy the 'android' folder to /node_modules/react-native-sound/ and rebuilt. It seems no more error. |
The Error was appearing when running Jest, and being flagged as soon as the 'react-native-sound' was being imported. I'm having success by importing a mock file into the test, containing:
|
Make sure that you run |
@vladbars comment worked for me. I had to cd into the |
PLEASE, PUT IN THE DOCUMENTATION WITH CAPITAL LATTERS: "REBUILD THE APP AFTER IMPORT THE LIBRARY" Thanks a lot. |
The error is regarding the following line of code in
sound.js
:I have followed the instructions exactly as outlined for IOS, so I have no idea why I am getting this error.
This module works perfectly on Android.
The text was updated successfully, but these errors were encountered: