I don't have an android phone, but i'm trying to develop for it anyway. The only way to test my application at the moment is to use the emulator, which I've read does not support audio recording. However, I read about the startup command "-audio " which allows audio input/output from your pc using the 'winaudio' backend. I haven't been able to get it to work though, is it possible to record using my pc's microphone? If so, what am I doing wrong?
4 Answers
Yes, it can. On Mac OSX, you must set the microphone on the emulator settings, after it's opened.
While the emulator is opened, on the right side bar (where the volume buttons are localized), click on the three dots (last button of the list) to open the emulator settings.
On the settings screen (called "Extended controls"), select Microphone and turn on the option "Virtual microphone uses host audio input".

- 420
- 5
- 9
-
After working for a long while on iOS, I had forgotten about this menu. I went back to Android and began having trouble with Speech Recognition and just thought that Android had suspended audio recording support newer OS versions of the emulators. Thanks a lot! – Josh May 04 '20 at 16:26
-
I turned on the option "Virtual microphone uses host audio input". But it still does not work. I tried to use Google Voice Search. It can't hear me. – Duong Phan Nov 27 '20 at 13:35
-
Awesome!! Thanks so much for this tip, was struggling since I was just getting silence on record. Works like a charm now – droid_dev Mar 13 '21 at 06:50
Recording audio is possible at least in the standard 2.3.3 emulator on Windows 7; I have tried it and it works. However, the recorded audio did sound a bit weird (slow) in my case. I did not investigate the cause.
You need to add audio recording + playback support to the emulator (Android SDK and AVD manager -> Virtual devices -> Edit -> Hardware -> New). Then use the [MediaRecorder API][1] to record (MediaRecorder.AudioSource.MIC).
Code is:
fMediaRecorder= new MediaRecorder();
fMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
fMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
fMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
fMediaRecorder.setAudioChannels(1);
fMediaRecorder.setAudioSamplingRate(8000);
fMediaRecorder.setOutputFile(fTmpFile.getAbsolutePath());
fMediaRecorder.prepare();
fMediaRecorder.start();
You also need
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
in your AndroidManifest.xml
Works for me, but Audio IS distorted.

- 19,513
- 22
- 110
- 155

- 208
- 2
- 6
-
will you please upload some source code that works on Windows7 to record the sound in android emulator ?? I really need it. – Shreyash Mahajan Aug 25 '11 at 13:33
-
Ok Thanks for your reply. I have done with my own. And its work on 1.6 also. – Shreyash Mahajan Aug 29 '11 at 04:05
-
I've used the 2.3.3 emulator never got this to work. But it works fine on the device. Keep your fingers crossed. – Deepak Bala Sep 27 '12 at 19:00
-
The built in speech recorder app also crashes in my emulator. Does that mean recording will not work on my machine? – user13267 Aug 12 '13 at 05:47
No. It is not possible to use the emulator for recording sound. You will have to code the logic of your program and then to deploy the actual apk to your phone, in order to test its functionality.
Please check this link as it has the official reference for my comment: http://developer.android.com/intl/es/guide/topics/media/audio-capture.html

- 351
- 4
- 15
To the best of my knowledge: To be able to use MediaRecorder you need to build the entire source so that you can use the recording facility, along with the option that you have mentioned.
- Get the source code of the version of android that you are targeting.
- Build the generic image by :
. build/envsetup.sh
lunch 1
(ie. choose the generic option, not simulator)make -j<number>
wherenumber
= #cores supported by your pc; exclude the angle brackets
cd out/target/.../generic
, ... represents the rest of the path upto generic; set environment variable ANDROID_PRODUCTION_OUT to this directory.- run the emulator from the out/host/.../bin directory with the -audio option.
This should ideally work.
The default sdk does not support your use case, as you have rightly mentioned here.
-
I'm on windows, I just read that building the source code is only possible on OSX and linux. Is this correct? Is there any other way? – Steve Mar 10 '11 at 03:45
-
I think thats correct. Also:for Froyo and less, you need 32-bit linux; for gingerbread and above, you need 64-bit linux. I am not aware of any other way... – Mno Mar 10 '11 at 04:16