question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sound.MAIN_BUNDLE: undefined - can't find file

See original GitHub issue

I am using Android 5.01 React-native 0.19

after creating object to access my file

const notifySound = new Sound('notify.aac', Sound.MAIN_BUNDLE, (error) => {

I got error { message: 'resource not found', code: -1 } I followed all steps in the documentation, but then console.log - Sound.MAIN_BUNDLE and it’s undefined

{ [Function: Sound]
I/ReactNativeJS( 9413):   enable: [Function],
I/ReactNativeJS( 9413):   MAIN_BUNDLE: undefined,
I/ReactNativeJS( 9413):   DOCUMENT: undefined,
I/ReactNativeJS( 9413):   LIBRARY: undefined,
I/ReactNativeJS( 9413):   CACHES: undefined }

which comes from sound.js file and this code

Sound.MAIN_BUNDLE = RNSound.MainBundlePath;
Sound.DOCUMENT = RNSound.NSDocumentDirectory;
Sound.LIBRARY = RNSound.NSLibraryDirectory;
Sound.CACHES = RNSound.NSCachesDirectory;

Solution In the end, I put my files into android/app/src/main/res/raw, but it would be nice to put this file directly in my service folder

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
maurovisintincommented, Dec 20, 2016

For Android I got the same error if I try to reproduce a downloaded file. I got the example working ( putting the audio in /res/raw -> relative path) Everything works fine on IOS (simulator and physical device) if i put reproduce files from Sound.DOCUMENT

For Android i tried DocumentDir/MainBundleDir/DownloadDir but none of these seem to work. Library can’t seem to load the file from these sources. Any idea?

2reactions
zmxvcommented, Apr 27, 2016

@fritx You’re right. I should probably check if filename is an absolute path in the if condition.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-sound/Help - Gitter
MAIN_BUNDLE refers to android/app/src/main/res/raw directory which can be used to bundle sound files as the part of the APK itself but it increases...
Read more >
Error in react native app 'failed to call function, __ ...
I believe the error arises when React can't find the main.jsbundle file in your app's main bundle at runtime.
Read more >
How to use the react-native-sound.MAIN_BUNDLE function in ...
To help you get started, we've selected a few react-native-sound. ... forEach((s) => { // Load the sound file from the app bundle...
Read more >
cannot read properties of undefined (reading 'path') multer ...
multer npm: TypeError: Cannot read property 'path' of undefined ... The path is throwing an error because "file" is not defined inside "req"...
Read more >
@taoqf/react-native-fs - npm
require the module var RNFS = require('@taoqf/react-native-fs'); // get a list of files and directories in the main bundle RNFS.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found