I keep getting this error when trying to initialize and AudioRecord object, in an attempt to record sounds using the emulator using Eclipse.
I have tried with various bit sampling rates, 8000 is the only one that is valid, but the error continues to appear. I have tried on various versions of the sdk, 1.5, 1.6, 2, 2.2 and 2.3.1. (and combinations of with the AVD).
Here is the code:
       Log.v(TAG, "About to initialize recording");
   //int[] samplingRates = {44100, 22050, 16000, 11025, 8000};
   int[] samplingRates = {8000};
    for (int i = 0; i < samplingRates.length; ++i)
    {
        try
        {
            Log.d(TAG,"Trying sampling rate: " + samplingRates[i]);
            int min = AudioRecord.getMinBufferSize(samplingRates[i], 
                    AudioFormat.CHANNEL_CONFIGURATION_MONO,
                    //AudioFormat.CHANNEL_IN_MONO,
                    AudioFormat.ENCODING_PCM_16BIT);
            Log.d(TAG,"MinBufferSize: " + min);
            AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.MIC, samplingRates[i],
                    AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, min);
            if (record.getState() == AudioRecord.STATE_INITIALIZED)
            {
                Log.d("Recorder", "Audio recorder initialised at " + record.getSampleRate());
                return record;
            }
            record.release();
            record = null;
        }
        catch (IllegalArgumentException e)
        {
            // Try the next one.
            Log.d(TAG,"Initialization failed");
        }
    }
    // None worked.
    return null;
The error occurs on instantiation, AudioRecord record = new etc.
Has anyone seen this same problem, it seems to be a straight forward request so i´m suprised if this a bug, particular as I can´t get it working with different versions.
I have created the AVDs with Audio Record capabilities. Is there anything else I have to configure?
I have seen a couple of other posts on the same issue, but no replies.
Thanks in advance
Chris