Skip to content
This repository was archived by the owner on Aug 21, 2020. It is now read-only.
This repository was archived by the owner on Aug 21, 2020. It is now read-only.

undefined is not an object (evaluating 'AudioRecorderManager.checkAuthorizationStatus') - android #89

Closed
@ghost

Description

Got this error when executing AudioExample on Android.

This, added to the response of react-native link react-native-audio which is rnpm-link info iOS module react-native-audio is already linked makes me think that the example is not runneable on Android.

Any ideas?

Activity

rakannimer

rakannimer commented on Sep 16, 2016

@rakannimer
Contributor

Hey !
Thanks for reporting this. I updated the example code, can you try again and report back ?

jsierles

jsierles commented on Sep 17, 2016

@jsierles
Owner

Fixed in #91.

ghost

ghost commented on Sep 19, 2016

@ghost

Solved. Thanks so much.

neilsarkar

neilsarkar commented on Oct 8, 2016

@neilsarkar
Contributor

In case anyone else is new to react-native and doesn't realize this, you need to restart (either via react-native run-ios or react-native run-android or through the IDEs) after doing react-native link react-native-audio -- the js reloading won't pick up the newly linked native libraries.

bruckmatthew

bruckmatthew commented on Feb 2, 2017

@bruckmatthew

This issue seems to still persist unless i'm missing something?

undefined1

Running on Android emulator and on android device
React Native 0.40
react-native-audio 3.10.8
run:
rnpm link react-native-audio
react-native link react-native-audio

Restarted with entirely new project.

Added permission to AndroidManifest.xml

Below is the code snippet which I think it might be having problems with.

import {
Platform,
PermissionsAndroid,
} from 'react-native';
import { AudioRecorder, AudioUtils } from 'react-native-audio';

class RecordScene extends Component {

state = {
  currentTime: 0.0,
  recording: false,
  finished: false,
  //Must change back to DocumentDirectoryPath for release. However no directory path 
  audioPath: AudioUtils.MusicDirectoryPath + '/test.aac',
  hasPermission: undefined,
};

prepareRecordingPath(audioPath){
    AudioRecorder.prepareRecordingAtPath(audioPath, {
        SampleRate: 22050,
        Channels: 1,
        AudioQuality: "Low",
        AudioEncoding: "aac",
        AudioEncodingBitRate: 32000
    });
}

componentDidMount() {
  this._checkPermission().then((hasPermission) => {
    this.setState({ hasPermission });

    if (!hasPermission) return;

  });
}

_checkPermission() {
  if (Platform.OS !== 'android') {
    return Promise.resolve(true);
  }

  const rationale = {
    'title': 'Microphone Permission',
    'message': 'AudioExample needs access to your microphone so you can record audio.'
  };

  return PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, rationale)
    .then((result) => {
      console.log('Permission result:', result);
      return (result === true || result === PermissionsAndroid.RESULTS.GRANTED);
    });
}

_record() {
	this.prepareRecordingPath(this.state.audioPath);
	AudioRecorder.startRecording();
	this.setState({recording: true});
}
TechGuyVN

TechGuyVN commented on Feb 10, 2017

@TechGuyVN

I got the same problem, can you solve it?

HolaMan

HolaMan commented on Jun 8, 2017

@HolaMan

I got the same problem.
RN 0.44
react-native-audio 3.2.2

[update]
sorry for the wrong comment.
After confirmation, it require ios rebuild before testing
It's okay to me now.

ybalaev1

ybalaev1 commented on Jan 21, 2020

@ybalaev1

react-native link react-native-audio
cd ios && pod install && cd ..
delete app in your device
react-native run-ios
close the terminal with starting the server
react-native start --reset-cache

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jsierles@neilsarkar@TechGuyVN@rakannimer@HolaMan

        Issue actions

          undefined is not an object (evaluating 'AudioRecorderManager.checkAuthorizationStatus') - android · Issue #89 · jsierles/react-native-audio