1. Are you ready for the Galaxy S20? Here is everything we know so far!

Phantom uninitialized audioRecord error

Discussion in 'Android Development' started by hackster84, May 27, 2014.

  1. hackster84

    hackster84 Lurker
    Thread Starter


    I am a hardware programmer who is new to the Android programming world. I'm running into an error that doesn't quite make sense and I'm looking for a little insight as to how I might go about fixing it.

    I'm writing an app that does serial communication using the 3.5mm audio jack. I have one app that runs perfectly, so in order to create the new app, I simply imported the code from the previous app into the new app. After making very minor alterations to the main activity java file and the layout.xml file, I get an error that says that says "startRecording() called on an uninitialized AudioRecord." I've gone through the whole app and I am unable to find why the system thinks that the AudioRecord isn't initialized. I've even gone as far as to copy the initialization of the AudioRecord to the line that immediately precedes the call to startRecording() with no change in the error message. The initialization and call that causes the error is as follows:

    [HIGH]AudioRecord _audioRecord;
    _audioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT,
    _sampleFrequency, AudioFormat.CHANNEL_IN_MONO,
    AudioFormat.ENCODING_PCM_16BIT, recBufferSize);
    What could possibly be causing this error, especially since literally the exact same code works in another application? The code that I removed from the original app is simply a button click listener that changes the frequency of some audio output, so it shouldn't have any effect on the initialization code since it doesn't even get called until the button gets pushed. Any thoughts on the matter would be greatly appreciated. Thanks in advance for your help,


    1. Download the Forums for Android™ app!


  2. panospapajohn

    panospapajohn Lurker

    Hi Chris,

    I am having the exact same problem when I try to use this class. Have you figure out what the problem was?


Share This Page