title: Android emulator closes without warning
body: <p>I'm using Linux Pop!OS 19.04 and have tried installing the Android Emulator. It does start but it closes within about 30seconds every time.</p>
  
  <p>I have Java 8 installed through 'OpenJDK-8-JDK' and I can successfully build Android packages and side load them onto my phone without a problem.</p>
  
  <p>After installing the Android SDK into the /usr/local/android here is what I did;</p>
  
  <ol>
  <li><p>Change into the tools bin dir</p>
  
  <pre><code>cd /usr/local/android/sdk/tools/bin
  sudo chmod +x
  </code></pre></li>
  <li><p>Install system images (must be done as root)</p>
  
  <pre><code>sudo ./sdkmanager "system-images;android-25;google_apis;x86"
  sudo ./sdkmanager --licenses
  </code></pre>
  
  <p>Say 'y' to all
      sudo touch ~/.android/repositories.cfg</p></li>
  <li><p>List available Android Virtual Devices to install (done as user)</p>
  
  <pre><code>./avdmanager list
  </code></pre></li>
  <li><p>Create a test Android Virtual Device (AVD)</p>
  
  <pre><code>./avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
  </code></pre>
  
  <p>custom hardware profile: no</p></li>
  <li><p>List AVDs</p>
  
  <p>Now I get the following when I list through avdmanager</p>
  
  <pre><code>./avdmanager list avd
  Available Android Virtual Devices:
      Name: test
      Path: /root/.android/avd/test.avd
    Target: Google APIs (Google Inc.)
            Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
  </code></pre></li>
  <li><p>Start emulator</p>
  
  <pre><code>cd /usr/local/android/sdk/emulator
  ./emulator -avd test
  </code></pre></li>
  </ol>
  
  <p>It then loads the emulator and I can start applications and browse around until it just crashes/closes the program.</p>
  
  <p>I tried installing Android studio and setting up the AVD through there, same thing happened. I've tried different models and android versions for my AVD, same thing.</p>
  
  <p><strong>Update: Log a crash</strong></p>
  
  <p>I managed to log a crash by using</p>
  
  <pre><code>$ANDROID_HOME/emulator/emulator -avd test -gpu guest -logcat v
  </code></pre>
  
  <p>log</p>
  
  <pre><code>08-22 13:50:03.169  2703  2839 V NativeCrypto: Read error: ssl=0xb0a32640: I/O error during system call, Connection reset by peer
  08-22 13:50:03.170  2703  2839 V NativeCrypto: SSL shutdown failed: ssl=0xb0a32640: I/O error during system call, Broken pipe
  08-22 13:50:03.195  3551  3551 W dex2oat : Unexpected CPU variant for X86 using defaults: x86
  08-22 13:50:03.195  3551  3551 W dex2oat : Mismatch between dex2oat instruction set features (ISA: X86 Feature string: smp,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt) and those of dex2oat executable (ISA: X86 Feature string: smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt) for the command line:
  08-22 13:50:03.195  3551  3551 W dex2oat : /system/bin/dex2oat --runtime-arg -classpath --runtime-arg &amp; --instruction-set=x86 --instruction-set-features=smp,ssse3,-sse4.1,-sse4.2,-avx,-avx2,-lock_add,-popcnt --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=x86 --instruction-set-features=default --dex-file=/data/user/0/com.google.android.gms/app_fb/f.apk --oat-fd=44 --oat-location=/data/user/0/com.google.android.gms/app_fb/f.dex --compiler-filter=speed
  08-22 13:50:03.195  3551  3551 I dex2oat : /system/bin/dex2oat --dex-file=/data/user/0/com.google.android.gms/app_fb/f.apk --oat-fd=44 --oat-location=/data/user/0/com.google.android.gms/app_fb/f.dex --compiler-filter=speed
  08-22 13:50:03.232  3551  3551 I dex2oat : dex2oat took 36.457ms (threads: 2) arena alloc=323KB (331648B) java alloc=76KB (78168B) native alloc=966KB (989744B) free=2MB (2155984B)
  08-22 13:50:03.234  2703  2839 W System  : ClassLoader referenced unknown path: 
  08-22 13:50:03.253  2022  3550 I GoogleURLConnFactory: Using platform SSLCertificateSocketFactory
  08-22 13:50:03.262  2022  3550 I GoogleURLConnFactory: Using platform SSLCertificateSocketFactory
  08-22 13:50:03.387  2022  2716 W ConfigurationChimeraPro: Got null configs for com.google.android.gms.auth.account.base
  08-22 13:50:03.415  2022  2716 W Conscrypt: Could not set socket write timeout:
  08-22 13:50:03.416  2022  2716 W Conscrypt:    java.lang.reflect.Method.invoke(Native Method)
  08-22 13:50:03.416  2022  2716 W Conscrypt:    com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
  08-22 13:50:03.552  2022  2716 W Conscrypt: Could not set socket write timeout:
  08-22 13:50:03.552  2022  2716 W Conscrypt:    java.lang.reflect.Method.invoke(Native Method)
  08-22 13:50:03.552  2022  2716 W Conscrypt:    com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@11743470:13)
  08-22 13:50:03.678  2022  2716 W GLSUser : [AppCertManager] IOException while requesting key: 
  08-22 13:50:03.678  2022  2716 W GLSUser : java.io.IOException: Invalid device key response.
  08-22 13:50:03.678  2022  2716 W GLSUser :  at eyw.a(:com.google.android.gms@11743470:14)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at eyw.a(:com.google.android.gms@11743470:65)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at eyu.a(:com.google.android.gms@11743470:8)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at eyq.a(:com.google.android.gms@11743470:1)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at eyp.a(:com.google.android.gms@11743470:10)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms@11743470:7)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at edr.call(:com.google.android.gms@11743470:3)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at mmu.run(:com.google.android.gms@11743470:26)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at mse.run(:com.google.android.gms@11743470)
  08-22 13:50:03.678  2022  2716 W GLSUser :  at java.lang.Thread.run(Thread.java:761)
  08-22 13:50:07.717  1603  1634 W ActivityManager: Unable to start service Intent { act=com.google.android.gms.drive.ApiService.RESET_AFTER_BOOT flg=0x4 cmp=com.google.android.gms/.drive.api.ApiService (has extras) } U=0: not found
  emulator: Saving state on exit with session uptime 119964 ms
  </code></pre>
  
  <p><strong>Update: config.ini</strong></p>
  
  <p>Here is my config.ini</p>
  
  <pre><code>PlayStore.enabled = false
  abi.type = x86
  avd.ini.encoding = UTF-8
  hw.accelerometer = yes
  hw.audioInput = yes
  hw.battery = yes
  hw.cpu.arch = x86
  hw.dPad = no
  hw.device.hash2 = MD5:fc85b2d34337b54227366eb43de4cfef
  hw.device.manufacturer = Generic
  hw.device.name = 5.4in FWVGA
  hw.gps = yes
  hw.lcd.density = 160
  hw.lcd.height = 854
  hw.lcd.width = 480
  hw.mainKeys = yes
  hw.sdCard = yes
  hw.sensors.orientation = yes
  hw.sensors.proximity = yes
  hw.trackBall = no
  image.sysdir.1 = system-images/android-24/google_apis_playstore/x86/
  sdcard.size = 2048M
  tag.display = Google Play
  tag.id = google_apis_playstore
  disk.dataPartition.size = 6442450944
  hw.ramSize=3072
  </code></pre>
  
  <p><strong>Update: Another crash log</strong></p>
  
  <p>This time it doesn't complain about a missing key.</p>
  
  <pre><code>08-28 09:48:58.109 12476 12476 W art     : Unexpected CPU variant for X86 using defaults: x86
  08-28 09:48:58.114 12476 12476 D ICU     : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
  08-28 09:48:58.129 12476 12476 E memtrack: Couldn't load memtrack module (No such file or directory)
  08-28 09:48:58.129 12476 12476 E android.os.Debug: failed to load memtrack module: -2
  08-28 09:48:58.130 12476 12476 I Radio-JNI: register_android_hardware_Radio DONE
  08-28 09:48:58.139 12476 12476 D AndroidRuntime: Calling main entry com.android.commands.settings.SettingsCmd
  08-28 09:48:58.144 12476 12476 D AndroidRuntime: Shutting down VM
  emulator: emulator_window_fb_update
  
  emulator: emulator_window_fb_update
  
  emulator: emulator_window_fb_update
  
  emulator: emulator_window_fb_update
  
  08-28 09:49:03.851  1602  2032 D AlarmManagerService: Kernel timezone updated to -600 minutes west of GMT
  08-28 09:49:03.852  1602  2030 D AlarmManagerService: Setting time of day to sec=1566949744
  08-28 09:49:04.002  1602  2030 W AlarmManagerService: Unable to set rtc to 1566949744: No such device
  [ 8042.781849] healthd: battery l=100 v=0 t=0.0 h=2 st=2 chg=a
  emulator: emulator_window_fb_update
  
  emulator: emulator_window_fb_update
  
  emulator: emulator_window_fb_update
  
  emulator: emulator_window_fb_update
  
  emulator: Saving state on exit with session uptime 73706 ms
  </code></pre>
  
  <p><strong>Work around</strong></p>
  
  <p>Create an alias which restarts the emulator everytime it crashes.</p>
  
  <pre><code>alias tnsa="tns run android --device emulator-5554"   # Run in emulator
  alias em="$ANDROID_HOME/emulator/emulator -avd samsung_galaxy_s8 -gpu guest -no-audio -verbose" 
  alias eml="while true; do pkill -f android; sleep 2; tnsa &amp;; em &amp;&gt; ~/emulator.log; done"
  </code></pre>
  
  <p>This is terrible, but what I'm currently working with.</p>