14

I am trying to run the Speech Recorder that comes with the Android 2.2 emulator. The problem is that the moment I click the "Record" button:

enter image description here

It aborts with an error message "The application Speech Recorder (process com.android.speechrecorder) has stopped unexpectedly. Please try again."

enter image description here

The problem is that trying again doesn't help.

Now, I searched StackOverflow and I combed the entire Internet and I found many reports of the same problem, without any working solution.

My conclusion is that, for some strange reason, the Android emulator is capable of using the Windows audio device for output, but not for input.

Why is that?

I know that other virtualization software (e.g. VMWare) have no problem using both output and input sections of the host's audio device.

Also, if Speech Recorder never worked for the emulator for anyone, why put it there?

Surely this has worked for someone. Is there a way to make Speech Recorder work for me, too?

I am using Windows XP 32-bit and my AVD is defined with an SD card (mounted upon start).

Update: I followed the suggestion by @Klaus to try and see whether any exceptions are thrown. I did so by simply typing ddms.bat at the command line to launch a stand-alone version of DDMS (with a logcat display at the bottom). Sure enough, I receive the following exception upon clicking the "Record" button:

03-29 14:16:58.195: ERROR/AudioRecord(303): Could not get audio input for record source 1
03-29 14:16:58.195: ERROR/srec_jni(303): initCheck error -22 
03-29 14:16:58.205: DEBUG/SpeechRecorderActivity(303): run audio capture thread
03-29 14:16:58.205: WARN/dalvikvm(303): threadid=8: thread exiting with uncaught exception (group=0x4001d800)
03-29 14:16:58.215: ERROR/AndroidRuntime(303): FATAL EXCEPTION: Thread-9
03-29 14:16:58.215: ERROR/AndroidRuntime(303): java.lang.NullPointerException
03-29 14:16:58.215: ERROR/AndroidRuntime(303):     at com.android.speechrecorder.SpeechRecorderActivity$4.run(SpeechRecorderActivity.java:192)
03-29 14:16:58.285: WARN/ActivityManager(59):   Force finishing activity com.android.speechrecorder/.SpeechRecorderActivity
03-29 14:16:58.904: DEBUG/dalvikvm(59): GC_FOR_MALLOC freed 13324 objects / 656184 bytes in 197ms
03-29 14:16:59.915: INFO/ARMAssembler(59): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x20db68:0x20dc24] in 1247352 ns
03-29 14:17:05.251: DEBUG/SpeechRecorderActivity(303): stopRecording

How do I proceed from here? I didn't write the Speech Recorder app, so I don't know what causes the NullPointerException at SpeechRecorderActivity.java line 192. I believe this has something to do with an earlier logcat message:

Could not get audio input for record source 1

But the question again is why?

Why wasn't it able to "get audio input for record source 1"?

srf
  • 2,410
  • 4
  • 28
  • 41
  • 1
    Errr...are any exceptions caught? All you put is the Force Close message, usually a lot of exceptions are caught prior to that. Show us the exceptions (ALL of them) from your LogCat output. – Codemonkey Mar 29 '11 at 12:59
  • 1
    Could have sworn you had a comment here - it crashes for me too: `03-29 14:13:38.075: ERROR/AudioRecord(282): Recording parameters are not supported: sampleRate 11025, channelCount 1, format 1 03-29 14:13:38.075: ERROR/srec_jni(282): initCheck error -22 03-29 14:13:38.104: ERROR/AndroidRuntime(282): FATAL EXCEPTION: Thread-8 03-29 14:13:38.104: ERROR/AndroidRuntime(282): java.lang.NullPointerException 03-29 14:13:38.104: ERROR/AndroidRuntime(282): at com.android.speechrecorder.SpeechRecorderActivity$4.run(SpeechRecorderActivity.java:192)` Not sure why you care though. :3 No source code. – Codemonkey Mar 29 '11 at 14:15
  • @Klaus Yes, there was a question I posted but I deleted it after I found out the answer myself (see above). Thanks and +1 again. :) – srf Mar 29 '11 at 14:23
  • What else do you expect out of a Java app? – Mrchief Jan 18 '12 at 05:53

1 Answers1

3

The reason you're having this issue is that the emulator doesn't have an audioInput to hook. Your best bet is to plug a real device in and do testing there.

Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94
  • 3
    http://developer.android.com/guide/topics/media/index.html -- specifically, paragraph 3 says `Note that the emulator doesn't have hardware to capture audio or video, but actual mobile devices are likely to provide these capabilities, accessible through the MediaRecorder class.` – Chris Cashwell Mar 30 '11 at 14:43
  • 1
    If you plug a microphone into your system, the emulator should use it. See this discussion: http://groups.google.com/group/android-developers/browse_thread/thread/b4be83e1ce5ef8ac – Brian Mar 30 '11 at 15:02
  • @Brian I already have a microphone plugged into my system. It doesn't use it. @Chris Thanks and +2. – srf Apr 01 '11 at 20:58
  • The documentation is wrong. It works if you have a mic plugged in. – Mrchief Jan 18 '12 at 05:52
  • @Mrchief the documentation _is_ wrong, and you _can_ get audio input working from the emulator. Unfortunately it's not always as simple as plugging in a microphone. Some machines apparently have trouble with it. On my MacBook Pro, it works great under OSX, but under my Windows 7 VM, it doesn't. Audio input was listed as a limitation in the documentation until sometime recently. – Chris Cashwell Jan 18 '12 at 12:27
  • Very true. This android emulator is the worst emulator I've seen. I'd audio working on it for a while on my Win 7 box. One fine day, it stops working. Even the builtin audio recorder app crashes. – Mrchief Jan 18 '12 at 18:36
  • I have the same problem both on Windows 7 and on Ubuntu 11.10. I also tried to install the x86 porting on VirtualBox, but there's no way to make it work :( – enzom83 Feb 21 '12 at 21:27
  • why have the speech recorder at all though, in the emulator, if it isn't supposed to work with sound input? – user13267 Aug 12 '13 at 06:46