Comments (50)
none of the suggested solutions worked for me, running react-native link
works, however it doesn't seems to do anything, I had this error as well, and I was able to resolve it by manually adding RNSound.xcodeproj
to Libraries
folder and drag and drop libRNSound.a
to Link Binary with Libraries
of my project.
from react-native-sound.
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
from react-native-sound.
Unhandled JS Exception: undefined is not an object (evaluating 'RNSound.IsAndroid')
Deleting all files in iOS build folder and restarting the packager solved the issue
rm -rf ios/build/*
from react-native-sound.
Had the same experience as @DeanKamali - react-native link
only linked to my first target, not the others.
So just keep that in mind. In the end I manually selected my dev target and linked libRNSound.a by dragging (see docs), re-built from Xcode and it worked.
from react-native-sound.
I have the same issue, and I tried reinstalling node module and recompiling, but it didn't help.
reinstalled by: npm install react-native-sound --save
recompiled by: react-native run-ios
is this what you did? @will-ockmore
from react-native-sound.
I finally resolved this issue by following steps (I don't know which one fixed the issue, so I'll put everything I did)
- Kill processes on port 8081
rm -rf ios/build/*
(Delete all files in iOS build folder)- Reboot
- Open up in XCode and change the scheme from building for a
Release
toDebug
.
Now I see RNSound
object on ReactNative.
from react-native-sound.
I get
undefined is not an object (evaluating '_reactNativeSound.Sound.MAIN_BUNDLE')
probably related.
react-native link
sets react-native-sound
where the docs say RNSound
. I changed that manually and the above error is what I end up with after copying a sound to the specified folder android/app/src/main/res/raw
and running react-native run-android
again.
import issue. After reading Sound.js it was an easy fix:
// wrong
import {Sound} from 'react-native-sound'
// right
import Sound from 'react-native-sound'
// or
import {default as Sound} from 'react-native-sound'
from react-native-sound.
I was able to fix the issue undefined is not an object (evaluating 'RNSound.IsAndroid')
on iOS π₯.
What I did was just to reinstall react-native-sound npm install react-native-sound --save
and instead of linking it to xcode/android manually, I used react-native link react-native-sound
to link it automatically, after that the error disappeared.
Just for reference, to play a sound just open xcode, and drag-drop your sound file into the root of the xcode project library:
--AppName
----Libraries
----AppNameTests
----Products
----Resources
----SoundFile.wav
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:
import React from 'react';
import { TouchableWithoutFeedback, Text } from 'react-native';
import Sound from 'react-native-sound';
class MyComponent extends Component {
playSound() {
const mySound = new Sound('tap.wav', Sound.MAIN_BUNDLE, (e) => {
if (e) {
console.log('error', e);
} else {
console.log('duration', mySound.getDuration());
mySound.play();
}
});
}
render() {
return (
<TouchableWithoutFeedback onPress={this.playSound.bind(this)}>
<Text>Play Sound!</Text>
</TouchableWithoutFeedback>
);
}
}
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 react-native run-ios
, that's all!
Hope this is helpful! π
from react-native-sound.
@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 myProjectTests
selected rather than myProject
. Once I fixed this I did not receive any error on iOS.
Android: According to RN docs RNSound
package should be added to getPackages()
method of MainApplication.java
rather than MainActivity.java
. Once I changed this the error went away.
I am using RN version 0.39.2.
Hope this helps.
from react-native-sound.
I solved this problem.
Solution; close android / ios emulator and close android Studio / XCode and close terminal / cmd. Restart all and it worked.
from react-native-sound.
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.
from react-native-sound.
I had this issue on iOS briefly, just after running yarn add react-native-sound
and react-native link
.
I fixed it by recompiling. I forgot to do that π. This is probably not the same issue as what others are experiencing though.
from react-native-sound.
I'm able to solve this error, by re-linking the libraries again
react-native link
react-native run-ios
from react-native-sound.
I only get the error when running unit tests!
Building an playing sounds works perfectly fine.
What could be the reason for it?
from react-native-sound.
Make sure that you run pod install
after react-native link react-native-sound
in case you are use pods. In other case link it manually #36 (comment)
from react-native-sound.
Are you on the latest version? Are you seeing the issue with https://github.com/zmxv/react-native-sound-demo ?
from react-native-sound.
Yes, I am on the latest version. I will clone from the link you provided and get back to you asap.
from react-native-sound.
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 npm install
and rnpm link
from react-native-sound.
Weird. Neither the demo app nor the native module directly depends on RNCookieManager
https://github.com/zmxv/react-native-sound/search?utf8=%E2%9C%93&q=RNCookieManagerIOS
https://github.com/zmxv/react-native-sound-demo/search?utf8=%E2%9C%93&q=RNCookieManagerIOS
from react-native-sound.
The error is this line: if (Platform.OS === 'ios') { invariant(RNCookieManagerIOS,
from react-native-sound.
This error seems to have nothing to do with the sound module.
from react-native-sound.
Back to the original issue, do you have any idea what's causing it?
from react-native-sound.
FYI, I am able to successfully run the demo project. Digging the sample audio.
from react-native-sound.
Having the same issue, any updates @Frosty92?
from react-native-sound.
Unfortunately no.
from react-native-sound.
I'm unable to reproduce the issue with the demo app.
from react-native-sound.
Mine was solved after reintalling node modules and recompiling - haven't had the issue since (touch wood)
from react-native-sound.
Stack trace is:
Unhandled JS Exception: undefined is not an object (evaluating 'RNSound.IsAndroid')
RCTFatal + 104
-[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 588
__invoking___ + 140
-[NSInvocation invoke] + 286
-[NSInvocation invokeWithTarget:] + 54
-[RCTModuleMethod invokeWithBridge:module:arguments:] + 1887
-[RCTBatchedBridge _handleRequestNumber:moduleID:methodID:params:] + 680
__33-[RCTBatchedBridge handleBuffer:]_block_invoke.456 + 1274
_dispatch_call_block_and_release + 12
_dispatch_client_callout + 8
_dispatch_queue_drain + 1048
_dispatch_queue_invoke + 595
_dispatch_client_callout + 8
_dispatch_root_queue_drain + 890
_dispatch_worker_thread3 + 98
_pthread_wqthread + 1129
start_wqthread + 13
Once I reload the page, it just shows one line
Cannot read property 'IsAndroid' of undefined
from react-native-sound.
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
from react-native-sound.
@RinorDreshaj there is no such folder as far as I can see. where do you find it?
from react-native-sound.
I have got the same issue with Android undefined is not an object (evaluating 'RNSound.IsAndroid')
from react-native-sound.
Luckily, I fixed by rebuild android and react-native run-android. Thanks all
from react-native-sound.
@anhtata Please help me i am also facing issue in android. I tried
react-native run-android
but still same issue
from react-native-sound.
Looks like there is a Pull Request already on this issue.
from react-native-sound.
Interesting - it's possible the differences between react-native link react-native-sound
and the manual instructions may be due to #88
from react-native-sound.
I'm closing this as folks have posted helpful solutions that seem to work for people
from react-native-sound.
@benvium I'm not sure why would you close an issue and I'm seeing tone of people encountering this error?
from react-native-sound.
@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.
from react-native-sound.
I'm using newer react-native-cli
react-native-cli: 2.0.1
react-native: 0.41.2
xcode Version 8.2.1 (8C1002)
from react-native-sound.
@DeanKamali ok. I just tried:
react-native init TEST
cd TEST
npm i react-native-sound --save
react-native link
open ios/TEST.xcodeproj/
# open build phases
... and for me it linked the library correctly. What happens when you try?
from react-native-sound.
@benvium I followed your steps verbatim and created new project and I can confirm that react-native link
correctly set things up.
I'm not sure why I encountered that issue earlier, however following the manual process is not a big deal.
Thanks for taking the time to check it out.
from react-native-sound.
@DeanKamali No problem. I'll re-close this ticket until the issue crops up again :-)
from react-native-sound.
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?
from react-native-sound.
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.
from react-native-sound.
You need to delete your derived data in XCode: /Users/{yourUserName}/Library/Developer/Xcode/DerivedData
from react-native-sound.
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 react-native link react-native-sound
as laid out in the initial instructions. That solved my problem.
from react-native-sound.
Linking doesn't work whether i relink the library or not, manual installation doesn't work either.
None of the above workaround worked aswell.
Build on ios, both debug and release tested.
App is native with a react-native view (so not created with create react-native app)
ps : fixed this by doing a pod install after linking the library. Now i got to get it to work.
DO NOT right click project and select add file, you won't be able to copy it if needed thus making the file unavailable if you delete if from folder (which is most likely the case because you don't download ressources in your app folder directly)
from react-native-sound.
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:
jest.mock('NativeModules', () => {
return {
RNSound: {
IsAndroid: true
}
};
});
from react-native-sound.
@vladbars comment worked for me. I had to cd into the ios
directory ad run pod install
.
from react-native-sound.
PLEASE, PUT IN THE DOCUMENTATION WITH CAPITAL LATTERS:
"REBUILD THE APP AFTER IMPORT THE LIBRARY"
Thanks a lot.
from react-native-sound.
Related Issues (20)
- Audio after playing not stopped
- Sound.setCategory('Playback') not working
- Play function stops working after playing multiple videos HOT 1
- Playing the next track in the done callback of the play() function doesn't work HOT 1
- Can not build in Windows HOT 4
- It is not working on Ios version 16.6 HOT 2
- Uncaught Error: Cannot read property 'IsAndroid' of null HOT 2
- React Native 0.71.0 incompatibility HOT 1
- Include Guidelines for Allowing Assets in Audio Files
- Can't play sound from "App Group" paths.
- onEnd callback is not fired on Android if setSpeed() HOT 4
- Γ Build failed with message C:\Users\91626\Downloads\testwindowsapp\node_modules\react-native-sound\windows\RNSoundModule\RNSoundModule\RNSoundPackage.cs(1,7): error CS0246: The type or namespace name 'ReactNative' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\91626\Downloads\testwindowsapp\node_modules\react-native-sound\windows\RNSoundModule\RNSoundModule\RNSoundModule.csproj]. Check your build configuration. HOT 3
- delay between sounds played HOT 3
- Is there a software update plan? HOT 1
- When I send voice note from android to IOS, then failed to load sound in IOS. HOT 1
- Wrong duration value when running methode getDuration()
- η°ε¨iOSη«―θΏθ½η¨εοΌζδΉιζεοΌδΈθ½ζζΎι³ι’ε’οΌ
- bugfixed: Can't play remote mp3 on iOS
- Is it possible to play sound synchronous?
- Error => {"extra": -1330794744, "what": -1003}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-sound.