Reputation: 39
My goal is to run the Android emulator in "-no-window" mode because I want to run it on a remote machine which does not have a monitor / graphics card attached. I have been struggling for days without success.
First, let me describe what works. I will then describe what doesn't, which is really what I want to achieve.
What is working
I can run the emulator on the remote machine without the "-no-window" flag. The remote machine is a bare metal machine (it's not a virtual machine) with Ubuntu installed. When the emulator runs, I can "see" it on my local display. Here is what I did:
ssh -Y username@my-remote-machine
$ uname -a Linux cell1 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux cd ~/Android/Sdk/emulator ./emulator -show-kernel -no-boot-anim -netdelay none -netspeed full -no-snapshot-load -avd Nexus_5X_API_22_64bit
I then waited a bit and the emulator would appear on my client machine under a minute.
I explored the UI a little bit and then pressed Ctrl-C in the console to stop the emulator gracefully. Things worked as expected and I saw the following in the console:
[ 123.257075] healthd: battery l=100 v=0 t=0.0 h=2 st=2 chg=a ^C emulator: Saving state on exit with session uptime 132314 ms
What is not working
I connected to the remote machine in the same way.
Then, I attempted to run the emulator with the "-no-window" flag because - ultimately - I want to run the emulator from within a cronjob and there will be no DISPLAY for it to appear in.
./emulator -show-kernel -no-boot-anim -netdelay none -netspeed full -no-snapshot-load -avd Nexus_5X_API_22_64bit -no-window
shell@generic_x86_64:/ $ ^C emulator: WARNING: Skipping state saving as emulator not finished booting.
My question is: does anyone know why the emulator didn't finish booting with the "-no-window" flag? How can I run the emulator on a remote machine (a bare metal machine) without a monitor? Any suggestion / help is appreciated.
Thanks very much!
Upvotes: 3
Views: 1561
Reputation: 180
It costed me a full day to understand that it was a simply image issue. Switching from the google apis versions to default ones fixed my problem.
Hope it helps
Upvotes: 0
Reputation: 177
I had the same issue for some time. Try adding these params to the emulator startup:
-qemu -enable-kvm -snapshot
Upvotes: 0
Reputation:
I've just run into the same problem. I successfully managed to boot once with -no-window
, but all subsequent attempts failed after using the emulator with a window for a bit.
From what I have found, it seems it may be something to do with the state being persisted (even though launching with -no-window
makes it detect a configuration change, and thus should be resetting the state).
If I launch with emulator -no-window -wipe-data -avd TEST_1234
(i.e. wiping the previous state), it will finish the boot process successfully, every time.
Subsequent launches using -no-window
without -wipe-data
also seem to work too:
$ emulator -no-window -avd TEST_1234
^Cemulator: Saving state on exit with session uptime 30735 ms
It's not an ideal solution if you need to switch between using the UI and using a headless configuration, but if you (like me) were just switching to the UI to visually verify something, and intend to manage everything using adb
in production, this should get around the issue.
Upvotes: 1