tracer0tong / android-emulator

Yet another Docker container with Android SDK and Android emulator
Apache License 2.0
246 stars 95 forks source link

Emulator hangs on startup screen with "android" flashing #21

Open TedOstin opened 7 years ago

TedOstin commented 7 years ago

Hey, any one still working on this? This is super helpful from the look of it. Also will this work on Azure VMs? I followed the steps to setup this on my Azure VM, i can see the container started, and i can even use VNC to open the android emulator. However it stuck at the startup screen with "android" flashing.

I am wondering if this is due to i am using the VM or i did not follow the steps correctly.

Thank you for your help.

Thanks Ted

tracer0tong commented 7 years ago

Hi, do you have enough memory and disk space to run container? It works not very fast, well, starts at least as usual Android VM, and if you are using weak machine it takes a lot of time get working instance. "Android" screen means that you passed to Android boot loader, but VM can stuck on out of memory or disk space.

rebelalliance11 commented 7 years ago

I also have this problem when trying to run it via the terminal with no GUI. I narrowed it down to the last command in the entrypoint.sh file. If I look at the logs, it just stops and hangs after a while. The last line in the log is:

emulator: ping command: /usr/local/android-sdk/tools/ddms ping emulator 22.6.4.0 "" "" ""

I also posted my question and ingfo about this on the Docker hub

tracer0tong commented 7 years ago

Well, this is a correct last line. Usually, when you are connecting by VNC it also shows some connection parameters. Could you provide your machine specs? Are you using Docker in Linux or Windows with Oracle VirtualBox VM?

rebelalliance11 commented 7 years ago

Hi I am using docker on a Linux Ubuntu server on Virtual Box VM. VM has 4GB memory and 30GB disk space

TedOstin commented 7 years ago

Thank you very much for responding. Sorry i was off town for a while. I just updated my Azure VM to 2 core and 14 GB memory and 28G local SSD and still has the same issue.

Here is what i did:

  1. I start up the android docker with the following command: sudo docker run -e "EMULATOR=android-22" -e "ARCH=x86" -d -P --name android tracer0tong/android -emulator
  2. Wait until i see it started by using adb devices
  3. I tried to use the default vnc port (5900) to connect it by usinvncviewer 127.0.0.1:32768
  4. Then i see the TightVNC:QEMU opened, but it shows "Android" and keep flashing.
  5. Waited more than an hour, still stuck on that load page.

Is there anything i am doing wrong? Thank you very much.

Ted

TedOstin commented 7 years ago

Any help please ? Still have this issue.

TedOstin commented 7 years ago

Some update on this. When i tried the default way to start the docker: "docker run -d -P --name android tracer0tong/android-emulator " it worked fine. I can use vncviewer to see the android emulator started.

But when i try: sudo docker run -e "EMULATOR=android-22" -e "ARCH=x86" -d -P --name android tracer0tong/android -emulator

sudo docker run -e "EMULATOR=android-22" -e "ARCH=armeabi-v7a" -d -P --name android tracer0tong/android -emulator

They are not working, it still hangs on the android load screen. I also tried "EMULATOR=android-21" It is still the same.

Can anyone help? Thanks

tracer0tong commented 7 years ago

Sorry, I have vacation, so no time to check issues. I will try do reproduce problem.

InsomniumBR commented 7 years ago

On my case the problem APPARENTLY was that my machine was missing this package: Intel x86 Atom_64 System Image

I have updated what was installed and selected this package that was not selected.

Running Windows 8.1 64bit / VS 2017

drywolf commented 7 years ago

@InsomniumBR I'm currently also trying to get the android-22 x86 version running on Windows 10 in Docker for Windows, and I'm also getting the behavior described above. (Emulator container begins booting, but is stuck on the flashing Android logo)

PS: the android-19 x86 version is working for me, the android-21 is also stuck at the logo

What do you mean by:

Intel x86 Atom_64 System Image I have updated what was installed and selected this package that was not selected.

What exactly did you change ? the Dockerfile ?

tracer0tong commented 7 years ago

@drywolf looks like @InsomniumBR rebuilt container by himself. I'm usually testing container from Dockerhub. Theoretically Android can stuck if he has not enough memory. If you can see logo - system started to boot (this is bootloader screen). Question is why he couldn't start. If you have tried to build container by yourself, try to install all ABIs from Dockerfile. All systems images and etc. Also try to use image from Dockerhub, which works at least for me on Windows 7.

InsomniumBR commented 7 years ago

@drywolf @tracer0tong Sorry guys! I am not using a docker or container. I just got here because I had the same symptoms on the title.

@drywolf I am out of office now, but I will try to remember. I was using Visual Studio 2017 with Android SDK Manager to debug some stuff here, and I could not boot an emulator based on x86 (Arm-based was working well.) So I found that package that I mentioned before inside the package lists to download from Android SDK manager. Then I recreated the AVD (android virtual device) selecting now x86_64 (something like that) instead of just x86. And It worked.

Sorry to no have more details on that. I am pretty new on Xamarin/Android/iOS development.

InsomniumBR commented 7 years ago

@drywolf @tracer0tong Sorry guys! I am not using a docker or container. I just got here because I had the same symptoms on the title.

@drywolf I am out of office now, but I will try to remember. I was using Visual Studio 2017 with Android SDK Manager to debug some stuff here, and I could not boot an emulator based on x86 (Arm-based was working well.) So I found that package that I mentioned before inside the package lists to download from Android SDK manager. Then I recreated the AVD (android virtual device) selecting now x86_64 (something like that) instead of just x86. And It worked.

Sorry to no have more details on that. I am pretty new on Xamarin/Android/iOS development.

drywolf commented 7 years ago

@tracer0tong Thanks for the reply. Up to now I only used the prebuild image from DockerHub, but I have just built the image myself and the behavior is the same (v21+ is stuck on the "Android" screen)

I looked at the adb log output for the v22 image, which gives the following:

I/qemu-props(    0): connected to 'boot-properties' qemud service.
W/auditd  (  915): type=2000 audit(0.0:1): initialized
I/auditd  (  915): type=1403 audit(0.0:2): policy loaded auid=4294967295 ses=4294967295
W/auditd  (  915): type=1404 audit(0.0:3): enforcing=1 old_enforcing=0 auid=4294967295 ses=4294967295
I/qemu-props(    0): receiving..
I/qemu-props(    0): received: dalvik.vm.heapsize=48m
I/qemu-props(    0): receiving..
I/qemu-props(    0): received: ro.config.low_ram=true
I/qemu-props(    0): receiving..
I/qemu-props(    0): received: qemu.sf.lcd_density=240
I/qemu-props(    0): receiving..
I/qemu-props(    0): received: qemu.hw.mainkeys=1
I/qemu-props(    0): receiving..
I/qemu-props(    0): received: qemu.sf.fake_camera=back
I/qemu-props(    0): receiving..
I/qemu-props(    0): exiting (5 properties set).
I/lowmemorykiller(    0): No kernel memory.pressure_level support (errno=2)
E/lowmemorykiller(    0): Kernel does not support memory pressure events or in-kernel low memory killer
--------- beginning of system
I/Vold    (  919): Vold 2.1 (the revenge) firing up
D/Vold    (  919): Volume sdcard state changing -1 (Initializing) -> 0 (No-Media)
I/SurfaceFlinger(  920): SurfaceFlinger is starting
I/SurfaceFlinger(  920): SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
D/libEGL  (  920): Emulator without GPU support detected. Fallback to legacy software renderer.
D/libEGL  (  920): loaded /system/lib/egl/libGLES_android.so
D/gralloc_goldfish(  920): Emulator without host-side GPU emulation detected.
I/gralloc (  920): using (fd=11)
I/gralloc (  920): id           =
I/gralloc (  920): xres         = 480 px
I/gralloc (  920): yres         = 800 px
I/gralloc (  920): xres_virtual = 480 px
I/gralloc (  920): yres_virtual = 1600 px
I/gralloc (  920): bpp          = 16
I/gralloc (  920): r            = 11:5
I/gralloc (  920): g            =  5:6
I/gralloc (  920): b            =  0:5
I/gralloc (  920): width        = 74 mm (164.756760 dpi)
I/gralloc (  920): height       = 123 mm (165.203247 dpi)
I/gralloc (  920): refresh rate = 260.42 Hz
E/SurfaceFlinger(  920): hwcomposer module not found
W/SurfaceFlinger(  920): no suitable EGLConfig found, trying a simpler query
W/SurfaceFlinger(  920): EGL_SLOW_CONFIG selected!
I/SurfaceFlinger(  920): EGL information:
I/SurfaceFlinger(  920): vendor    : Android
I/SurfaceFlinger(  920): version   : 1.4 Android META-EGL
I/SurfaceFlinger(  920): extensions: EGL_KHR_get_all_proc_addresses EGL_ANDROID_presentation_time EGL_KHR_image_base EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer
I/SurfaceFlinger(  920): Client API: OpenGL_ES
I/SurfaceFlinger(  920): EGLSurface: 5-6-5-0, config=0x0
W/SurfaceFlinger(  920): no suitable EGLConfig found, trying a simpler query
W/SurfaceFlinger(  920): EGL_SLOW_CONFIG selected!
I/SurfaceFlinger(  920): EGL information:
I/SurfaceFlinger(  920): vendor    : Android
I/SurfaceFlinger(  920): version   : 1.4 Android META-EGL
I/SurfaceFlinger(  920): extensions: EGL_KHR_get_all_proc_addresses EGL_ANDROID_presentation_time EGL_KHR_image_base EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer
I/SurfaceFlinger(  920): Client API: OpenGL_ES
I/SurfaceFlinger(  920): EGLSurface: 5-6-5-0, config=0x0
I/SurfaceFlinger(  920): OpenGL ES informations:
I/SurfaceFlinger(  920): vendor    : Android
I/SurfaceFlinger(  920): renderer  : Android PixelFlinger 1.4
I/SurfaceFlinger(  920): version   : OpenGL ES-CM 1.0
I/SurfaceFlinger(  920): extensions: GL_EXT_debug_marker GL_OES_byte_coordinates GL_OES_fixed_point GL_OES_single_precision GL_OES_read_format GL_OES_compressed_paletted_texture GL
_OES_draw_texture GL_OES_matrix_get GL_OES_query_matrix GL_OES_EGL_image GL_OES_EGL_sync GL_OES_compressed_ETC1_RGB8_texture GL_ARB_texture_compression GL_ARB_texture_non_power_of_
two GL_ANDROID_user_clip_plane GL_ANDROID_vertex_buffer_object GL_ANDROID_generate_mipmap
I/SurfaceFlinger(  920): GL_MAX_TEXTURE_SIZE = 4096
I/SurfaceFlinger(  920): GL_MAX_VIEWPORT_DIMS = 4096
W/SurfaceFlinger(  920): no suitable EGLConfig found, trying a simpler query
W/SurfaceFlinger(  920): EGL_SLOW_CONFIG selected!
I/SurfaceFlinger(  920): EGL information:
I/SurfaceFlinger(  920): vendor    : Android
I/SurfaceFlinger(  920): version   : 1.4 Android META-EGL
I/SurfaceFlinger(  920): extensions: EGL_KHR_get_all_proc_addresses EGL_ANDROID_presentation_time EGL_KHR_image_base EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer
I/SurfaceFlinger(  920): Client API: OpenGL_ES
I/SurfaceFlinger(  920): EGLSurface: 5-6-5-0, config=0x0
D/SurfaceFlinger(  920): Set power mode=2, type=0 flinger=0xb685c000
E/SurfaceFlinger(  920): ro.sf.lcd_density must be defined as a build property
D/libEGL  (  979): Emulator without GPU support detected. Fallback to legacy software renderer.
D/libEGL  (  979): loaded /system/lib/egl/libGLES_android.so
D/gralloc_goldfish(  979): Emulator without host-side GPU emulation detected.

The emulator is stuck at this point and does not print any other log messages. For comparison, the v19 android image keeps outputting adb messages pretty much all the time during boot and even after it is already booted.

drywolf commented 7 years ago

@tracer0tong Which version of Docker are you using to run the image on Windows 7 ? "Docker Toolbox" or "Docker for Windows" ?

tracer0tong commented 7 years ago

@drywolf I'm using Kitematic, hope this project still alive. This is Oracle Virtual Box VM with Linux and Docker inside.

drywolf commented 7 years ago

Ok maybe using a VirtualBox based docker engine works arround this issue (I am using the "Docker for Windows" engine).

I have investigated this issue more deeply, and it seems that officially running the Android emulator in a virtualized environment (Docker, VMs, ...) has been dropped at some point (see https://developer.android.com/studio/run/emulator-acceleration.html#extensions)

I have tried several ways and multiple workarrounds to get the most current emulator + x86 android image versions running in docker, but to no avail (yet).

emulator: CPU Acceleration: DISABLED
emulator: CPU Acceleration status: KVM requires a CPU that supports vmx or svm
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM requires a CPU that supports vmx or svm

There are now just one or two ideas left that I want to try, but if it does not work out I will just stick with the old version of the SDK + emulator images (r19) to have a real cross-platform way to run the x86 emulator.

@tracer0tong in your docker Windows 7 environment, could you please try and install the cpu-checker and let me know what you get when you run kvm-ok inside the android docker container.

I am getting the following, which pretty much confirms what the latest Android emulator also tells:

root@8daf900b7e1b:/# kvm-ok
INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used
dimorinny commented 6 years ago

I have the same issue. I tried to run your container inside VirtualBox with boot2docker image.

tracer0tong commented 6 years ago

Last time I have tested container from Dockerhub, I think I should try to rebuild it to see how it works. If you don't need newest API versions, you can try to use the same container.

zoutepopcorn commented 6 years ago

@tracer0tong

I think the new API has to run on a main machine with CPU hardware acceleration.

I spotted another docker, running:

docker run -it --device /dev/kvm -p 5554:5554 -p 5555:5555 --env ANDROID_EMULATOR_EXTRA_ARGS="-skin 480x800" thedrhax/android-avd

For more info see readme https://github.com/thedrhax-dockerfiles/android-avd

I'm not on my machine, but will try it later on Arch or Ubuntu.

With kvm-ok you can check if your machine setup is OK.

@drywolf Can you run kvm-ok in your main machine (VM || OS)

After that, we can try to make it work running the container with commands like this

--device /dev/kvm

OR

--privileged

Update

I enabled Virtualization in my Bios https://wiki.archlinux.org/index.php/KVM

tracer0tong commented 6 years ago

@zoutepopcorn I will appreciate, if you can make pull request. Currently I'm not involved in Android development, but as I can see, many people using that project as template.

zoutepopcorn commented 6 years ago

If I have some time, look if I can edit the readme after we found out, whats working ...

I'm also trying to implement an webcam on this docker first

https://github.com/butomo1989/docker-android

9jadev commented 4 years ago

I just encountered this problem I am using the android emulator for flutter

crazydevlegend commented 1 year ago

I'm using Memu player to test my android apps, and run into this issues.. is this happening due to lack of memory space available? i don't think so - 2GB available yet... image