title: Android emulator never finishes booting when "-no-window" flag is used
body: <p>
  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.</p>
  
  
  
  <p>First, let me describe what works. I will then describe what doesn't, which is really what I want to achieve.</p>
  
  <p><strong>What is working</strong></p>
  
  <p>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:</p>
  
  <ol>
  <li>I ssh into the remote machine with the "-Y" flag so that the rendering will appear on my local machine:</li>
  </ol>
  
  <blockquote>
  <pre><code>ssh -Y username@my-remote-machine
  </code></pre>
  </blockquote>
  
  <ol start="2">
  <li>When connected to the remote machine over ssh, I would execute the emulator using this command:</li>
  </ol>
  
  <blockquote>
  <pre><code>$ 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
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li><p>I then waited a bit and the emulator would appear on my client machine under a minute. </p></li>
  <li><p>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:</p></li>
  </ol>
  
  <blockquote>
  <pre><code>[  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
  </code></pre>
  </blockquote>
  
  <p><strong>What is not working</strong></p>
  
  <ol>
  <li><p>I connected to the remote machine in the same way.</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <blockquote>
  <pre><code>./emulator  -show-kernel -no-boot-anim -netdelay none -netspeed full
  -no-snapshot-load -avd Nexus_5X_API_22_64bit  -no-window
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li>I waited 3 minutes in the hope that it would finish booting. But my hope was let down. How did I know the booting didn't finish? I learned that when I pressed Ctrl-C and saw the following in the console:</li>
  </ol>
  
  <blockquote>
  <pre><code>shell@generic_x86_64:/ $
  ^C
  emulator: WARNING: Skipping state saving as emulator not finished booting.
  </code></pre>
  </blockquote>
  
  <p>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.</p>
  
  <p>Thanks very much!</p>