title: jenkins Emulator occasionally hangs indefinitely on startup
body: <p><strong>Problem:</strong> when I try to build an android project on Jenkins, emulator occasionally hangs indefinitely on startup and the job finished: NOT_BUILT.</p>
  
  <p>I have Jenkins slaves running on Debian EC2 instances - not using any emulator snapshots, every run is fresh with a clean workspace, so I haven't been able to figure out the difference as to why sometimes they are starting correctly and more often not.
  In "Common emulator options", I checked the option: 'Reset emulator state at start-up'.</p>
  
  <p>Jenkins version: 1.642<br/>
  Android Emulator Plugin: 2.13.1</p>
  
  <pre><code>...    
      [android] Using Android SDK: /var/lib/jenkins/tools/android-sdk
      [android] Creating Android AVD: /var/lib/jenkins/.android/avd/hudson_it-IT_160_HVGA_android-22_armeabi-v7a.avd
      [android] /var/lib/jenkins/tools/android-sdk/tools/android create avd -f -a -s HVGA -n hudson_it-IT_160_HVGA_android-22_armeabi-v7a -t android-22 --abi armeabi-v7a
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb start-server
      * daemon not running. starting it now on port 6345 *
      * daemon started successfully *
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb start-server
      [android] Starting Android emulator
      $ /var/lib/jenkins/tools/android-sdk/tools/emulator -ports 6343,6344 -prop persist.sys.language=it -prop persist.sys.country=IT -avd hudson_it-IT_160_HVGA_android-22_armeabi-v7a -no-snapshot-load -no-snapshot-save -wipe-data -no-window
      resize2fs 1.42.13 (17-May-2015)
      The filesystem is already 140800 (4k) blocks long.  Nothing to do!
  
      emulator: WARNING: Increasing RAM size to 1GB
      Creating filesystem with parameters:
          Size: 576716800
          Block size: 4096
          Blocks per group: 32768
          Inodes per group: 7040
          Inode size: 256
          Journal blocks: 2200
          Label: 
          Blocks: 140800
          Block groups: 5
          Reserved block group size: 39
      Created filesystem with 11/35200 inodes and 4536/140800 blocks
      Creating filesystem with parameters:
          Size: 69206016
          Block size: 4096
          Blocks per group: 32768
          Inodes per group: 4224
          Inode size: 256
          Journal blocks: 1024
          Label: 
          Blocks: 16896
          Block groups: 1
          Reserved block group size: 7
      Created filesystem with 11/4224 inodes and 1302/16896 blocks
      emulator: warning: opening audio output failed
  
      emulator: UpdateChecker: skipped version check
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      connected to localhost:6344
      [android] Waiting for emulator to finish booting...
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb -s localhost:6344 shell getprop init.svc.bootanim
      error: device offline
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb connect localhost:6344
      [android] Timed-out after waiting 720 seconds for emulator
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb disconnect localhost:6344
      [android] Stopping Android emulator
      $ /var/lib/jenkins/tools/android-sdk/platform-tools/adb kill-server
      Finished: NOT_BUILT
  </code></pre>
  
  <p>Can Someone help me? Where and what is the problem?
  Thank to all.</p>