HelloAndroid emulator problem

Solution 1:

Summary
(You can see the full details below these summarized steps).

  1. Uninstall/Reinstall Android SDK to folder off of C:\ (no spaces in path)
  2. Re-create the AVD.
  3. Set the PATH environment variable for the new Android SDK folder locations
  4. Uninstall/reinstall the Android ADT Plugin in Eclipse.
  5. Configure the Android SDK location in Eclipse.
  6. Reboot (to reduce the CPU utilization)
  7. Run the emulator from the command line and set it to use all CPUs with High or "Real Time" priority. Make note of your CPU usage.
  8. Open Eclipse and run the app.

Details
I spent two days getting the emulator to run the HelloAndroid app. In my case the problem might have been a combination of an issue with the Android SDK installation and a CPU performance problem. I think something was causing the emulator to run extremely slowly making the emulator appear to hang. My PC is a my Windows 7 64-bit 6GB Intel i7 multi-core PC. Task Manager shows 8 CPUs on my PC on the Performance tag.

My symptom was the Android 2.2 AVD in the emulator appeared to hang when the nimated "Android" text was showing on the screen. The Home screen would never show up. This scenario happened over and over. I would often wait 30 minutes or 45 minutes to no avail.

My environment:

  • Android SDK Revision 12
  • Android 2.2 AVD
  • Windows 7 64-bit
  • Eclipse IDE for Java Developers Indigo Release Build id 20110615-0604
  • Intel Core i7 multi-core CPU, 6 GB, 1.6 GHz

I tried starting the emulator from the command line without starting Eclipse at the command prompt and that didn't help. The emulator still hung. I noticed that Task Manager showed my box at 50% CPU usage which seemed rather high. CPU 0 was pegged at 100%.

Here's what fixed it.

I uninstalled the Android SDK R12 and reinstalled it off the root of C: at C:\android-sdk. I had previously experienced problems because the Android SDK was located at "C:\Program Files" folder; the SDK has a bug that can't handle the space in the path. I ran "uninstall.exe" from the Android SDK folder to do the uninstall. Uninstalling took longer than installing.

I added ";C:\android-sdk\tools\;C:\android-sdk\platform-tools\" to the PATH environment variable.

I then deleted the AVD using SDK Manager and recreated it.

I uninstalled the ADT Plugin for Eclipse, restarted Eclipse, then reinstalled the ADT Plugin, then closed Eclipse.

I reconfigured Eclipse with the new Android SDK path (Window > Preferences > Android > SDK Location).

On the Task Manager Processes tab, I enabled "Show processes from all users". I then right clicked "emulator-arm.exe *32", then clicked "Set Affinity..." and noticed that the emulator was set to only use CPU 0 so I changed it to use all CPUs. I also set the emulator to "Real Time" priority.

Observing a 50% CPU Usage, I rebooted.

After rebooting, I started the emulator using the command line:

emulator @Android22

Android22 is the name of my AVD. I used task manager to set the affinity for the emulator to use all CPUs and set the priority to high. My CPU usage was now about 13%, mostly due to the emulator. The emulator took about 3 minutes to show the Home screen. Yay!

I then opened Eclipse with the HelloAndroid app and the app successfully ran in the emulator.

I have written out in detail what I did because the past two days have been a real pain. I noticed several posts about this issue with many people not seeming to have success. I performed steps mentioned in several posts but did not find one place that described the whole process.

Good luck. I hope this info helps someone.

Solution 2:

It's loading. You can check loading progress in logcat from DDMS or adb shell logcat.

It takes some time to load the emulator, but remember that you don't need to restart it when you update your code. You just hit Run as... in eclipse and it will take care of uploading and reinstalling into the emu.

Also remember that you can use your phone instead of the emulator. I usually use my phone when the pc I am working on is too slow.

Good luck with Android development!