qiuxiang / react-native-recording

React Native audio recording module used for DSP with Android + iOS
MIT License
110 stars 62 forks source link

null is not an object (evaluating 'RNAudioRecord.init') #43

Closed tGrothmannFluffy closed 1 year ago

tGrothmannFluffy commented 1 year ago

Hi there,

I am getting this error:

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'Recording.init')]
at node_modules/react-native-recording/lib/index.js:14:30 in default.init
at components/AudioTest.tsx:31:18 in recordSound

In AudioTest.tsx I just have a button that calls recordSound (basically copied from the README):

import Recording from "react-native-recording";

...

async function recordSound() {
  await PermissionsAndroid.requestMultiple([
    PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
  ]);

  Recording.init({
    bufferSize: 4096,
    sampleRate: 44100,
    bitsPerChannel: 16,
    channelsPerFrame: 1,
  });

  const listener = Recording.addRecordingEventListener((data) =>
    console.log(data)
  );

  Recording.start();

  // stop recording
  Recording.stop();
  listener.remove();
}

Can you tell me what I am doing wrong?


I am using expo on Android version "react-native-recording": "^0.5.1",

tGrothmannFluffy commented 1 year ago

Turns out it was expo. I ejected to use react-native-cli and it works.