jsierles / react-native-audio

Audio recorder library for React Native
MIT License
1.16k stars 539 forks source link

Unhandled JS Exception: undefined is not an object (evaluating 'AudioRecorderManager.checkAuthorizationStatus') #83

Closed emirdeliz closed 8 years ago

emirdeliz commented 8 years ago

I get this error after load app.

Unhandled JS Exception: undefined is not an object (evaluating 'AudioRecorderManager.checkAuthorizationStatus')

I look source of react-native and not found the module 'AudioRecorderManager'

componentDidMount() {
        let audioPath = AudioUtils.DocumentDirectoryPath + '/test.aac'

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

        AudioRecorder.onProgress = (data) => {
            this.setState({ currentTime: Math.floor(data.currentTime) })
        }

        AudioRecorder.onFinished = (data) => {
            this.setState({ record: audioPath })
        }
    }

buildRecord() {
        let buttonPlay = this.state.record?
            <Button rounded style={ Style.buttonPlay } onPress={ () => {
                AudioRecorder.playRecording()
            }}>
                <Icon name="ios-play" />
            </Button>: null

        return (
            <View style={ Style.containerDescription }>
                <Button rounded style={ Style.buttonRecord } onPress={ AudioRecorder.startRecording() }
                    onPressOut={ AudioRecorder.stopRecording() }>
                    <Icon name="ios-microphone" />
                </Button>
                { buttonPlay }
            </View>
        )
    }

About react

"react": "~15.2.1", "react-native": "^0.31.0",

emirdeliz commented 8 years ago

I fixed this running the comand: 'react-native upgrade', then including again with 'rnpm link react-native-audio'.

WARNING: This command remove all plugins installed. After is necessary register again

cfournel commented 7 years ago

doing this with react-native-git-upgrade ( the new react-native upgrade tool ) + linking doesnt work.

tmaly1980 commented 7 years ago

In my case, I am using wix' react-native-navigation, which has it's own getPackages() defined in MainApplication.java. I needed to keep it synced with the default getPackages() that 'react-native link' modifies. After I got that copied, it works:

  protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
            new ReactNativeAudioPackage(),
            new RNSoundPackage(),
.....