0

NPM version : 10
React-Native Library : react-native-get-music-files

Installation :
npm i --save react-native-get-music-files
rnpm link

Things I Have Already Tried :
rnpm link react-native-get-music-files
react-native link
npm install
react-native run-android
REINSTALLING
MAKING A NEW PROJECT

Details :
Its documentation says add import com.reactlibrary.RNReatNativeGetMusicFilesPackage; but when automatically linking , it adds com.cinder72.musicfiles.RNReactNativeGetMusicFilesPackage;
Manually it is showing com.reactlibrary.RNReatN... is not found.
Automatically everything is working fine.

Error :
In the react-native-get-music-files/index.js

import { NativeModules, Platform } from 'react-native';

const { RNReactNativeGetMusicFiles } = NativeModules;

const MusicFiles = {
getAll(options){

return new Promise((resolve, reject) => {

if(Platform.OS === "android"){
RNReactNativeGetMusicFiles.getAll(options,(tracks) => {
resolve(tracks);
},(error) => {
resolve(error);
});
}else{
RNReactNativeGetMusicFiles.getAll(options, (tracks) => {
if(tracks.length > 0){
resolve(tracks);
}else{
resolve("Error, you don't have any tracks");
}
});
}

});

}
}
export default MusicFiles;

It says RNReactNativeGetMusic files is undefined.
I tried console log NATIVEMODULES and it shows nothing as RNReactNativeGetMusic or anything similar.

Comments
  • 1
    If you had Metro bundler running when you did npm install, you need to restart it
    then you need to do react-native run-android/ios
    After adding dependency you need to run again so that native code is recompiled again.

    If still fails, try:
    react-native start --resetCache

    That will start metro bundler as if new one

    If all fails, read docs again and check if react-native link did all the work it should do, it failed me today linking react-native-gesture-handler
  • 0
    @gitpush Yes i checked. Can you try installing react-native-get-music-files and then linking it because i tried making a new project and then linking.
    I tried manually linking.
Add Comment