Android emulator hanging with black screen

I recently experienced a situation where Android Studio’s x86 emulator would not start.

It just showed a black screen with no apparent progress.

 

To investigate I connected Android Device Monitor to the emulator.

LogCat showed a lot of messages and they seemed to repeat over and over.

 

I decided to pause the emulator to examine the log.

Found and followed Christoper Orr’s advice here:

telnet localhost 5554
avd stop

 

Checked the LogCat messages and noticed this section:

I/ServiceManager(16997): Waiting for service SurfaceFlinger...
I/SurfaceFlinger(17248): SurfaceFlinger is starting
I/SurfaceFlinger(17248): SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
D/libEGL(17248): Emulator has vendor provided software renderer, qemu.gles is set to 2.
D/libEGL(17248): loaded /vendor/lib/egl/libEGL_swiftshader.so
D/libEGL(17248): loaded /vendor/lib/egl/libGLESv1_CM_swiftshader.so
D/libEGL(17248): loaded /vendor/lib/egl/libGLESv2_swiftshader.so
D/gralloc_ranchu(17248): Emulator without host-side GPU emulation detected.
E/gralloc_ranchu(17248): Could not find software fallback module!?
E/gralloc_ranchu(17248): [ 07-04 12:54:38.858 17248:17248 E/ ]
E/gralloc_ranchu(17248): connect: failed with fd -1 errno 22
E/gralloc_ranchu(17248): [ 07-04 12:54:38.858 17248:17248 E/ ]
E/gralloc_ranchu(17248): Failed to connect to host (QemuPipeStream)!!!
E/gralloc_ranchu(17248): gralloc: Failed to get host connection
E/SurfaceFlinger(17248): hwcomposer module not found
E/SurfaceFlinger(17248): ERROR: failed to open framebuffer (I/O error), aborting
A/libc(17248): Fatal signal 6 (SIGABRT), code -6 in tid 17248 (surfaceflinger)
A/libc(17248): [ 07-04 12:54:38.858 1319: 1319 W/ ]
A/libc(17248): debuggerd: handling request: pid=17248 uid=1000 gid=1003 tid=17248
I/ServiceManager(17212): Waiting for service SurfaceFlinger...
I/ServiceManager(17212): [ 07-04 12:54:38.860 17256:17256 E/ ]
I/ServiceManager(17212): debuggerd: Unable to connect to activity manager (connect failed: Connection refused)

 

Decided to check the emulator configuration.

Noticed that the emulator was configured to use software graphics.

Changed this to hardware graphics, started the emulator again and noticed that it started normally. The workaround solved the problem.

 

Conclusion

If the Android Studio emulator hangs with a black screen, try checking the LogCat messages and try switching graphics mode.