Giter Club home page Giter Club logo

Comments (50)

DeanKamali avatar DeanKamali commented on June 20, 2024 30

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.

Roconda avatar Roconda commented on June 20, 2024 19

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.

RinorDreshaj avatar RinorDreshaj commented on June 20, 2024 6

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.

onpaws avatar onpaws commented on June 20, 2024 6

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.

sydneyitguy avatar sydneyitguy commented on June 20, 2024 5

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.

sydneyitguy avatar sydneyitguy commented on June 20, 2024 4

I finally resolved this issue by following steps (I don't know which one fixed the issue, so I'll put everything I did)

  1. Kill processes on port 8081
  2. rm -rf ios/build/* (Delete all files in iOS build folder)
  3. Reboot
  4. Open up in XCode and change the scheme from building for a Release to Debug.

Now I see RNSound object on ReactNative.

from react-native-sound.

ThaJay avatar ThaJay commented on June 20, 2024 4

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.

bntzio avatar bntzio commented on June 20, 2024 3

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.

tsanthosh avatar tsanthosh commented on June 20, 2024 2

@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.

selcukitmis avatar selcukitmis commented on June 20, 2024 2

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.

tuthanh82 avatar tuthanh82 commented on June 20, 2024 2

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.

Jarred-Sumner avatar Jarred-Sumner commented on June 20, 2024 1

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.

novalagung avatar novalagung commented on June 20, 2024 1

I'm able to solve this error, by re-linking the libraries again

react-native link
react-native run-ios

from react-native-sound.

andrekovac avatar andrekovac commented on June 20, 2024 1

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.

vladbars avatar vladbars commented on June 20, 2024 1

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.

zmxv avatar zmxv commented on June 20, 2024

Are you on the latest version? Are you seeing the issue with https://github.com/zmxv/react-native-sound-demo ?

from react-native-sound.

Frosty92 avatar Frosty92 commented on June 20, 2024

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.

Frosty92 avatar Frosty92 commented on June 20, 2024

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.

zmxv avatar zmxv commented on June 20, 2024

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.

Frosty92 avatar Frosty92 commented on June 20, 2024

The error is this line: if (Platform.OS === 'ios') { invariant(RNCookieManagerIOS,

from react-native-sound.

zmxv avatar zmxv commented on June 20, 2024

This error seems to have nothing to do with the sound module.

from react-native-sound.

Frosty92 avatar Frosty92 commented on June 20, 2024

Back to the original issue, do you have any idea what's causing it?

from react-native-sound.

Frosty92 avatar Frosty92 commented on June 20, 2024

FYI, I am able to successfully run the demo project. Digging the sample audio.

from react-native-sound.

will-ockmore avatar will-ockmore commented on June 20, 2024

Having the same issue, any updates @Frosty92?

from react-native-sound.

Frosty92 avatar Frosty92 commented on June 20, 2024

Unfortunately no.

from react-native-sound.

zmxv avatar zmxv commented on June 20, 2024

I'm unable to reproduce the issue with the demo app.

from react-native-sound.

will-ockmore avatar will-ockmore commented on June 20, 2024

Mine was solved after reintalling node modules and recompiling - haven't had the issue since (touch wood)

from react-native-sound.

sydneyitguy avatar sydneyitguy commented on June 20, 2024

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.

dmwallace avatar dmwallace commented on June 20, 2024

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.

wilbyang avatar wilbyang commented on June 20, 2024

@RinorDreshaj there is no such folder as far as I can see. where do you find it?

from react-native-sound.

anhtata avatar anhtata commented on June 20, 2024

I have got the same issue with Android undefined is not an object (evaluating 'RNSound.IsAndroid')

from react-native-sound.

anhtata avatar anhtata commented on June 20, 2024

Luckily, I fixed by rebuild android and react-native run-android. Thanks all

from react-native-sound.

snsekar avatar snsekar commented on June 20, 2024

@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.

tsanthosh avatar tsanthosh commented on June 20, 2024

Looks like there is a Pull Request already on this issue.

from react-native-sound.

benvium avatar benvium commented on June 20, 2024

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.

benvium avatar benvium commented on June 20, 2024

I'm closing this as folks have posted helpful solutions that seem to work for people

from react-native-sound.

DeanKamali avatar DeanKamali commented on June 20, 2024

@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.

benvium avatar benvium commented on June 20, 2024

@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.

DeanKamali avatar DeanKamali commented on June 20, 2024

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.

benvium avatar benvium commented on June 20, 2024

@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.

DeanKamali avatar DeanKamali commented on June 20, 2024

@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.

benvium avatar benvium commented on June 20, 2024

@DeanKamali No problem. I'll re-close this ticket until the issue crops up again :-)

from react-native-sound.

nickhillwd avatar nickhillwd commented on June 20, 2024

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.

ofirgeller avatar ofirgeller commented on June 20, 2024

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.

jpapillon avatar jpapillon commented on June 20, 2024

You need to delete your derived data in XCode: /Users/{yourUserName}/Library/Developer/Xcode/DerivedData

from react-native-sound.

lukkyjoe avatar lukkyjoe commented on June 20, 2024

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.

tirrorex avatar tirrorex commented on June 20, 2024

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.

CodeMuz avatar CodeMuz commented on June 20, 2024

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.

atrombet avatar atrombet commented on June 20, 2024

@vladbars comment worked for me. I had to cd into the ios directory ad run pod install.

from react-native-sound.

marcusdotenv avatar marcusdotenv commented on June 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.