Saturday, April 2, 2011

Android Virtual Device (AVD) Emulator stopped working

I have been playing with Android Virtual Device and once I ran the "Hello World" application (read: copy-and-pasted from Android Development Guide) I thought I had conquered the world. My inflated sense of achievement didn't last long before the Android Virtual Device stopped working altogether. I had enough memory available and hard drive was not an issue but still the Virtual Device refused to start without giving much details. I even tried the best Tech Support answer and restarted the machine but it didn't work.

The Eclipse SDK did not show any specific error message or exit code, here is what the Eclipse SDK console showed:
[2011-04-02 19:16:32 - Emulator]
[2011-04-02 19:16:32 - Emulator] This application has requested the Runtime to terminate it in an unusual way.
[2011-04-02 19:16:32 - Emulator] Please contact the application's support team for more information.

The AVD was working perfectly fine earlier and I didn't remember changing anything that may have broken it. Based on the little information available online specific to this error and AVD, I stopped and restarted ADB (Android Debug Bridge) but that didn't help either.

I tried launching the Android SDK and AVD
Manager from within Eclipse (Window > Android SDK and AVD Manager) and it still didn't start the virtual device. The emulator.exe application would simply not show up in the Task Manager. Then I tried to launch the emulator through commandline and that helped resolve the issue. device2 was the name of the AVD.
>emulator -avd device2
Failed to allocate memory: 8 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

Aha! That reminds me that I had changed the Device RAM from 256 to 1024MB and it had not started successfully after that change.

Solution: Edit the Device settings and change the RAM allocation to a lower number. I change it to 512MB and the emulator starts working.

I wonder why 1GB of RAM was too much for the Android Virtual Device manager to allocate when I have 3GB of physical RAM, 2GB of paging file and the Windows Task Manager was showing less than 2000MB under "Commit Charge" (i.e. more than 3000MB was available).

12 comments:

  1. I had fought through this problem for over 3 days. Yes, reducing the RAM size to 512 solved my problem of not being able to start my emulator on Android SDK 3.1 to support Honeycomb Fragment work. Thank you so much!

    ReplyDelete
  2. Hi Francis,
    I'm glad this little post helped resolved your problem!

    ReplyDelete
  3. Thought you might be interested to know, on my system I have 8gb of RAM, yet I was unable to set the Device ram size to 2048, but when lowering it to 1024 it worked.

    ReplyDelete
  4. Hi Imlast,
    Thank you for the feedback. Hopefully newer versions of Android SDK will have this issue ironed out to at least some degree.

    ReplyDelete
  5. I was stuck with this problem for more than a week and wasnt able to debug the error. This post really helped.. thanks

    ReplyDelete
  6. Hi,
    This post really helped me a lot....thanksssss

    ReplyDelete
  7. Thank you very much! You saved my day:-)

    ReplyDelete
  8. I tried to do what you did but it didn't work for me. I tried reduce to 512 and 256 and the error repeats.
    Somebody have other suggestion?

    ReplyDelete
  9. Thank you.
    I applied your method and I got success

    ReplyDelete
  10. This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. symulator androida

    ReplyDelete