Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNSound.IsAndroid bug #128

Closed
zakster12 opened this issue Mar 7, 2017 · 16 comments
Closed

RNSound.IsAndroid bug #128

zakster12 opened this issue Mar 7, 2017 · 16 comments

Comments

@zakster12
Copy link

zakster12 commented Mar 7, 2017

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

@benvium
Copy link
Collaborator

benvium commented Mar 7, 2017

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

@zakster12
Copy link
Author

zakster12 commented Mar 7, 2017

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.

@Samoy

This comment has been minimized.

@onpaws
Copy link

onpaws commented Mar 23, 2017

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

@asadm
Copy link

asadm commented Mar 31, 2017

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.

@ZhouXiongXiong
Copy link

在安卓上还是报一样的错,我已经link了,这该怎么解决呢?

@saudpunjwani101
Copy link

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

@szlapinski
Copy link

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

@astrotars
Copy link

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

@gvenk
Copy link
Contributor

gvenk commented Aug 30, 2017

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

@dohvis
Copy link

dohvis commented Dec 19, 2017

same error. I create project from react-native init

@mojombo
Copy link
Contributor

mojombo commented Jan 8, 2018

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

@TobiasLauer
Copy link

Same error.

@radik
Copy link

radik commented Feb 20, 2018

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

@arash-hacker
Copy link

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

@paulmelnikow
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests