Giter Club home page Giter Club logo

Comments (14)

tsanthosh avatar tsanthosh commented on July 2, 2024 2

@chachachacha @rowinf @nycoliver @kilgoremaskreplica @cavilaho

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.

rowinf avatar rowinf commented on July 2, 2024 1

It's working for me in 0.30. I had the same error, but I found something wrong with my android project configuration. For me, I forgot my import statement in MainApplication.java and my compile project(':RNSound') was in the wrong place. Hope that helps someone!

from react-native-sound.

peternann avatar peternann commented on July 2, 2024 1

If you followed the READMe accurately, you might have added the getPackages method into MainActivity.java

The README is wrong (at the time of typing).
The correct class to add to is MainApplication.java

I think this is the reason that react-native link react-native-sound works - It mods the correct file.

Please correct the README ASAP. Shitty trap for new users...

from react-native-sound.

nycoliver avatar nycoliver commented on July 2, 2024

I get this issue on ios with rnpm install react-native-sound but manual installation seems to work fine.

from react-native-sound.

jlsandri avatar jlsandri commented on July 2, 2024

@zmxv Also experiencing this bug on RN 0.30 >. Any word on a solution that doesn't involve subverting npm?

from react-native-sound.

nycoliver avatar nycoliver commented on July 2, 2024

@kilgoremaskreplica
Try removing the library and reinstall with
npm install react-native-sound
rnpm link react-native-sound

from react-native-sound.

 avatar commented on July 2, 2024

Working for me on RN 0.32. I solved this issue by manually linking, right this:

android/settings.gradle

include ':RNSound', ':app'
project(':RNSound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')

android/app/build.gradle

dependencies {
...
    compile project(':RNSound')
...

android/app/src/main/java/com/myApp/MainApplication.java

. . .
import com.zmxv.RNSound.RNSoundPackage;
. . .
protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          . . .
          new RNSoundPackage()
      );
}

from react-native-sound.

2ducanhpham avatar 2ducanhpham commented on July 2, 2024

react native 0.34 not working

from react-native-sound.

BenjaminPaap avatar BenjaminPaap commented on July 2, 2024

At least for iOS I can confirm that this library is working on react native 0.34.1

from react-native-sound.

2ducanhpham avatar 2ducanhpham commented on July 2, 2024

i try. IOS is working, but Android not working

from react-native-sound.

cindybinle2 avatar cindybinle2 commented on July 2, 2024

I found problem , please update document https://github.com/facebook/react-native/blob/0.35-stable/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java

from react-native-sound.

snsekar avatar snsekar commented on July 2, 2024

I am also facing same issue. No solutions described above working for me

from react-native-sound.

bntzio avatar bntzio commented on July 2, 2024

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.

benvium avatar benvium commented on July 2, 2024

Thanks for this. The readme has been updated now. It's now recommended to use react-native link react-native-sound which means you don't need to manually perform the install steps any more.

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.