Q:

Android:How To Get Media Recorder Output In MP3 Format?

I am creating an app that contains voice recording and playing. Is it possible to record files in MP3 format?
I need output file as mp3 format. Thanks.

A:

There's currently no MP3 encoder built into the Android framework (as far as I know), so you can't do it out of the box. You need to add an MP3 encoding library to your project to do so.
For this, you can look at this stackoverflow post for a complete answer.

A:

2015 update:
MP3 is officially supported by android - (edit) - however, this is only for decoding, not encoding.
http://developer.android.com/guide/appendix/media-formats.html

Core Media Formats:  MP3   •  Mono/Stereo 8-320Kbps constant (CBR) or
  variable bit-rate (VBR)   MP3 (.mp3)

(edit) - For smaller file sizes, you can use an .mp4. You can set it up with:
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

A:

There is definitely an MP3 encoder on the Android framework. 
Like I answered here on stackoverflow all you need to do is:
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setOutputFile(Environment.getExternalStorageDirectory()
        .getAbsolutePath() + "/myrecording.mp3");
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.prepare();
recorder.start();

The important part here is the setOuputFormat and the setAudioEncoder. MediaRecorder records playable mp3 if you're using MediaRecorder.OutputFormat.MPEG_4 and MediaRecorder.AudioEncoder.AAC together.
The funny thing is that this solution was a result of my experimenting with what works, and I have no idea as to why it works. I was hoping somebody could shed some light on this in the comments.
EDIT
As @JohnSmith and a few other pointed out in the comments, this does not encode the audio in MP3 format and there is no in-built MP3 encoder on Android.
The reason this solution seems to work is that MediaPlayer recognizes the encoding as AAC before beginning the track (regardless of the file extension). So although the output file's mime type is audio/mp4, the encoding is most definitely AAC.

