React-native-sound: RNSound.IsAndroid bug

Created on 7 Mar 2017  路  16Comments  路  Source: zmxv/react-native-sound

React Native - 0.42.0
React Native Sound - 0.9.1

I have only this snippet of code, nothing special:

const whoosh = new Sound(requireAudio, (error) => {
            if (error) {
                console.log('error', error);
            } else {
                whoosh.setSpeed(1);
                console.log('duration', whoosh.getDuration());
                whoosh.play(() => whoosh.release());
            }
        });

but the error is shown when it's trying to import the module, not on execution
screen shot 2017-03-07 at 1 41 09 pm

build question

Most helpful comment

Manually adding libRNSound to 'Linked Farmeworks...' in XCode resolved for me
screen shot 2018-02-20 at 10 14 25 pm

All 16 comments

This suggests the library isn't linked. Have you run react-native link and re-built the application?

Yes, I did. Hese is the output:

react-native link react-native-sound
Scanning 665 folders for symlinks in /Users/user/Workspace/MyApp/node_modules (5ms)
rnpm-install info Linking react-native-sound android dependency 
rnpm-install info Android module react-native-sound has been successfully linked 
rnpm-install info Linking react-native-sound ios dependency 
rnpm-install info iOS module react-native-sound has been successfully linked 
rnpm-install info Linking assets to ios project 
rnpm-install info Linking assets to android project 
rnpm-install info Assets have been successfully linked to your project 

I rebuild the project and again linking:

rnpm-install info Android module react-native-sound is already linked 
rnpm-install info iOS module react-native-sound is already linked 

And again I have the same error.

Same error.

Hitting this too. If there's any way I can be helpful with e.g. logs, more context, will be happy to.

For anyone stuck at this, you are probably forgetting rebuilding. ie: Uninstalling the APK and running react-native run-android to build and deploy apk again.

Native android libraries that you just linked need to be deployed. They can't be hot-reloaded.

鍦ㄥ畨鍗撲笂杩樻槸鎶ヤ竴鏍风殑閿欙紝鎴戝凡缁弆ink浜嗭紝杩欒鎬庝箞瑙e喅鍛紵

I'm running it on IOS simulator and getting this error. Linked the files and re-build the app, the error shows up when I import the library

Had the same issue when using Create React Native App. I had to eject from CRNA and now it works.

Any updates here? Still seems to be an issue with no resolution.

Are you using create-react-native-app? If so, your whole project needs to be pure JavaScript, and it won't work with react-native-sound.

What are the limitations of Create React Native App?

The main limitation of a Create React Native App project is that it must be written in pure JavaScript and not have any dependencies which rely on custom native code (i.e. ones which require running react-native link to work). This allows the projects to load directly on a phone without native compilation, and also means that it's not necessary to install or use Android Studio or Xcode.

https://github.com/react-community/create-react-native-app#what-are-the-limitations-of-create-react-native-app

same error. I create project from react-native init

I had this problem and found that react-native link react-native-sound had missed adding a line to the getPackages() method in MainApplication.java (deeply nested under the android directory of the RN project):

+       new RNSoundPackage()

This obviously prevented the native module from loading, causing it to be undefined in the JS. I'm guessing there are myriad ways the link command could fail. I figured out this specific problem by going through the Android native module docs here:

http://facebook.github.io/react-native/docs/native-modules-android.html

Same error.

Manually adding libRNSound to 'Linked Farmeworks...' in XCode resolved for me
screen shot 2018-02-20 at 10 14 25 pm

as @radik said just drag your react-native-sound project to .xcworkspace in libraries
after that from root project file select linked frameworks and libraries add libRNSound.a file
rebuild your project run your project
it's not bad also check this repo

I created a new app in React Native 0.60 and I encountered this issue once. To fix the issue I ran rm -rf ios/build and then react-native run-ios, which fixed it.

If you're still experiencing this issue, please open a new issue with steps to reproduce. If you have a universal solution, please open a pull request with a documentation update.

Was this page helpful?
0 / 5 - 0 ratings