Error RNSound.IsAndroid (React Native)

Getting this error - undefined - not an object (RNSound.IsAndroid rating)

I have already used this-responsive-native reaction-native-sound channel

my index.android.js code is- 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('x.mp3', 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> ); } } 
+5
source share
3 answers

In most cases, this error means that the package was incorrectly linked.

To make sure this is so: -

  • Go to android/app/src/main/java/.../MainApplication.java
  • Make sure you have this import in this file import com.zmxv.RNSound.RNSoundPackage;
  • Make sure this method has this call to new RNSoundPackage() , as shown below.

     @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new RNSoundPackage() // <-- New ); } 
  • If this does not work, follow the guide described on this wiki here: https://github.com/zmxv/react-native-sound/wiki/Installation

+2
source

I solved this by stopping responding to the packer by running the following commands:

 rm -rf node_modules/ npm install react-native link react-native-sound rn-nodeify --install --hack 

clean the project and rebuild the application. rn-nodeify was created for non-reactive packages, but in my case it works for react-native-sound .

0
source

I decided:

  • Delete the node_modules folder of your project.
  • Update the dependent response based on the native sound in the package.json file as:

     "react-native-sound": "git+ssh:// git@github.com :zmxv/react-native-sound.git#HEAD" 
  • fire npm install .

0
source

Source: https://habr.com/ru/post/1270026/


All Articles