Why am I getting IllegalArgumentException: Unsupported channel configuration?


I’m using AudioRecord to collect audio data from a headphone jack on Android like so:

int frequency = 44100;
int channelConfiguration = AudioFormat.CHANNEL_OUT_MONO;
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;

int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, frequency, channelConfiguration, audioEncoding, bufferSize);

However, I get an error that says

java.lang.IllegalArgumentException: Unsupported channel configuration.

I haven’t found anything helpful online, so I was wondering if anyone else had this issue.


I don’t know if this is what CaseyB meant, but I changed AudioFormat.CHANNEL_OUT_MONO to AudioFormat.CHANNEL_IN_MONO. This made the error go away.

Answered By – user3700215

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published