react-native-sound: RNSound.IsAndroid bug
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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 16 (2 by maintainers)
Manually adding libRNSound to ‘Linked Farmeworks…’ in XCode resolved for me
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.
I had this problem and found that
react-native link react-native-sound
had missed adding a line to thegetPackages()
method inMainApplication.java
(deeply nested under theandroid
directory of the RN project):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
as @radik said just drag your
react-native-sound
project to <your-project>.xcworkspace in libraries after that from root project file select linked frameworks and libraries addlibRNSound.a
file rebuild your project run your projectit’s not bad also check this repo
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.
https://github.com/react-community/create-react-native-app#what-are-the-limitations-of-create-react-native-app
Yes, I did. Hese is the output:
I rebuild the project and again linking:
And again I have the same error.
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 thenreact-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.
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
在安卓上还是报一样的错,我已经link了,这该怎么解决呢?
This suggests the library isn’t linked. Have you run
react-native link
and re-built the application?