Android emulator hanging on startup?
Asked Answered
Z

7

10

I've been modifying/editing parts of the Android platform, but have run into a problem when trying to test my edits. After making my changes to the platform source, I was able to successfully compile the source - thus creating system.img, ramdisk.img, and userdata.img.

When I go to test this in the emulator, the emulator just hangs on the "ANDROID_" screen, with the underscore blinking, but never seems to load. Any suggestions?

The command I used to run the emulator is as follows:

./emulator -system $HOME/android/platform/out/target/product/generic/system.img -ramdisk $HOME/android/platform/out/target/product/generic/ramdisk.img -data $HOME/android/platform/out/target/product/generic/userdata.img

Thanks,
Chris

Zel answered 23/6, 2010 at 16:53 Comment(0)
B
9

The first startup can take a while, especially on a slow machine but otherwise try running the adb logcat command to see the log output. That will help you determine what the problem could be.

Also if you like to skip supplying all the options to the emulator, i.e. -system and the other you can use the scripts supplied in the build folder. Run these commands from the open source project root folder:

source build/envsetup.sh
setpaths

The first one will run the envsetup script for Android that supplies a number of helpful commands. The second one sets up all the paths needed for Android platform development. Among them are the ANDROID_PRODUCT_OUT variable that informs the emulator where to look for the build images. It is set to the default folders that you have specified above. After running setpaths you can just start the emulator with your build by typing emulator on the command line.

Bearer answered 23/6, 2010 at 17:4 Comment(3)
Thanks for the tips. I tried running the adb logcat command, which did show me much more. It appears that the emulator is stuck in some sort of infinite boot loop. The loop starts with AndroidRuntime START <<<<<<<<<<<<<< And each iteration ends with I/ServiceManager( 25): service 'media.audio_flinger' died I/ServiceManager( 25): service 'media.player' died I/ServiceManager( 25): service 'media.camera' died I/ServiceManager( 25): service 'media.audio_policy' diedZel
Hmm, it could be that one of the critical services fails to start and because of that init will then try to restart the entire Android runtime. Depending on what machine you run on we have experienced some issues with audio in the emulator in which case the -noaudio option might help. Also, have you tried to do a build and just run the project "as is" without your changes. It is always good to know that the default system runs before trying out platform modifications.Bearer
Thanks BMB, it turned out that an error was occurring somewhere in my code. With further adjustments to my stuff, Android booted up successfully.Zel
A
10

I had this problem and fixed it by deleting the emulator and creating a new one. In eclipse:

  1. Menu Window -> Android SVK and AVD Manager
  2. Select Virtual devices (should be selected already)
  3. Select the emulator giving you problems
  4. Edit to see the setting and remember them.
  5. Delete the emulator.
  6. Create a new one that is the same as the old one.
  7. Start the emulator from here with the start button.

It started in about 30 seconds after I did that.

Normally the emulator starts in about 2-3 minutes for me. Then it mysteriously stopped working. I was seeing boot animation for 30 minutes before I gave up. Rebooting my laptop didn't help, which made me think it was a problem with the emulator settings, and I stumbled on this solution.

  • Note #1: Doing this will wipe your user data.
  • Note #2: As mentioned else where, it's a good idea to check "Enabled" for the Snapshot when you create or edit the emulator, this lets you do faster startup next time.
  • Note #3: My new emulator came up in chinese. That's kinda of weird :)
Astronomical answered 13/8, 2011 at 19:19 Comment(1)
Thanks for this, simple fix but not so obvoius... Saved me a lot of headache!Aqualung
B
9

The first startup can take a while, especially on a slow machine but otherwise try running the adb logcat command to see the log output. That will help you determine what the problem could be.

Also if you like to skip supplying all the options to the emulator, i.e. -system and the other you can use the scripts supplied in the build folder. Run these commands from the open source project root folder:

source build/envsetup.sh
setpaths

The first one will run the envsetup script for Android that supplies a number of helpful commands. The second one sets up all the paths needed for Android platform development. Among them are the ANDROID_PRODUCT_OUT variable that informs the emulator where to look for the build images. It is set to the default folders that you have specified above. After running setpaths you can just start the emulator with your build by typing emulator on the command line.

Bearer answered 23/6, 2010 at 17:4 Comment(3)
Thanks for the tips. I tried running the adb logcat command, which did show me much more. It appears that the emulator is stuck in some sort of infinite boot loop. The loop starts with AndroidRuntime START <<<<<<<<<<<<<< And each iteration ends with I/ServiceManager( 25): service 'media.audio_flinger' died I/ServiceManager( 25): service 'media.player' died I/ServiceManager( 25): service 'media.camera' died I/ServiceManager( 25): service 'media.audio_policy' diedZel
Hmm, it could be that one of the critical services fails to start and because of that init will then try to restart the entire Android runtime. Depending on what machine you run on we have experienced some issues with audio in the emulator in which case the -noaudio option might help. Also, have you tried to do a build and just run the project "as is" without your changes. It is always good to know that the default system runs before trying out platform modifications.Bearer
Thanks BMB, it turned out that an error was occurring somewhere in my code. With further adjustments to my stuff, Android booted up successfully.Zel
S
7

Try using adb logcat in the terminal to see what's happening with the emulator. When I did that I kept noticing

I/ServiceManager(  918): service 'media.audio_flinger' died
I/ServiceManager(  918): service 'media.player' died
I/ServiceManager(  918): service 'media.camera' died
I/ServiceManager(  918): service 'media.audio_policy' died

repeating every 10s or so. I tried enabling my cameras in the AVD and the emulator started working.

To enable the camera enter android avd in the terminal and set the front and back camera options.

Speaker answered 16/11, 2014 at 3:6 Comment(1)
How to set up front and back camera options using terminal? any commands?Historicism
U
3

I had a similar problem. The emulator was unresponsive and Android Studio was unable to deploy and run the application. My solution was the following: 1. Open the AVD manager 2. On right hand side menu of the virtual device issue the commands "Stop" and "Wipe data" 3. Then, do a cold boot of the virtual device and voila, it came back to life.

Untwist answered 2/1, 2019 at 22:13 Comment(0)
L
1

I normally have to restart it to get it to run. Today it wouldn't restart no matter what. Doing a ./adb logcat consistently showed 'waiting for device'. So I restarted it using Eclipse Android SDK and AVD Manager / Start... (option), un-checking the 'Launch from snapshot' option, and after the long grind of load it, the emulator works.

Laquanda answered 28/4, 2011 at 14:42 Comment(0)
M
1

My trick to get the emulator started on a weak machine (RAM: just 1 GB) is to start it as first thing after WinXP has finished booting. Further, using an emulator instance with a smaller resolution (smaller number of pixels on display to emulate, e.g. just 240x400) did also help.

Miltie answered 6/4, 2013 at 10:55 Comment(0)
M
0

I had a similar problem when running my emulator, and I solved it by starting the emulator from the command line with the command emulator -avd [your-avd-name] and then I got the Error ERROR | Not enough space to create userdata partition which I solved by cleaning up the disk. There was simply not enough free memory to create the Virtual Device in my case.

Mckeever answered 3/5 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.