Macos – Android SDK emulator freezes on a Mac running OS X 10.6 Snow Leopard

androidfreezejavamacmacos

I'm having trouble running the Android SDK on both of my Macs running OS X 10.6.2 Snow Leopard. This appears to be a 64-bit vs. 32-bit issue, as Snow Leopard now defaults to 64-bit everything, including the Java virtual machine.

I found this webpage with instructions on how to get the Android tools to run in the 32-bit Java VM, and I am now able to run the Android GUI tool to download SDK files, create AVM's, etc. However, when I try the Hello World tutorial and get to the point where I run my application under the Android emulator, everything goes south.

The emulator appears to start but it hangs (spinning beachball of death cursor) without displaying anything. (This only hangs the emulator; the rest of the system still works fine.) If I follow the exact same steps (minus the 32-bit Java hack) in a Windows virtual machine, everything works fine.

This occurs on both my Mac Pro tower and 13" MacBook Pro. Does anyone have any suggestions?

Best Answer

I was digging around the other day and saw this message appear on the terminal: emulator: warning: opening audio input failed I've seen this message many times before and I had always assumed that it was because the emulator didn't support sound or something like that. But I decided to try an experiment that one particular day. Turns out the emulator has a "-noaudio" command line option, and when I ran it with that, it worked!! So now I just run emulator with the -noaudio option always, no freezes. No sound support either, but at least I can run the emulator now.

Now, that works if I manually call the emulator from the command line. What about when the Eclipse ADT plugin calls it? Well I was feeling rather lazy at that point and didn't want to dig around in the ADT plugin to see if it had a "add these command line flags whenever running the emulator" option, so I made a little "wrapper" shell script for the emulator command that always adds the -noaudio option. It's a bit of a kludge, but it works. Here's how: (note: $ represents the shell prompt, don't type it yourself)

$ cd <WHERE YOU INSTALLED THE ANDROID SDK>/tools
$ mv emulator emulator.real
$ cat > emulator << EOF
#!/bin/sh
exec <WHERE YOU INSTALLED THE ANDROID SDK>/tools/emulator.real -noaudio $*
EOF
Related Question