3

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.

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.

After installing the Android SDK into the /usr/local/android here is what I did;

  1. Change into the tools bin dir

    cd /usr/local/android/sdk/tools/bin
    sudo chmod +x
    
  2. Install system images (must be done as root)

    sudo ./sdkmanager "system-images;android-25;google_apis;x86"
    sudo ./sdkmanager --licenses
    

    Say 'y' to all sudo touch ~/.android/repositories.cfg

  3. List available Android Virtual Devices to install (done as user)

    ./avdmanager list
    
  4. Create a test Android Virtual Device (AVD)

    ./avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
    

    custom hardware profile: no

  5. List AVDs

    Now I get the following when I list through avdmanager

    ./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
    
  6. Start emulator

    cd /usr/local/android/sdk/emulator
    ./emulator -avd test
    

It then loads the emulator and I can start applications and browse around until it just crashes/closes the program.

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.

Update: Log a crash

I managed to log a crash by using

$ANDROID_HOME/emulator/emulator -avd test -gpu guest -logcat v

log

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 & --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

Update: config.ini

Here is my config.ini

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

Update: Another crash log

This time it doesn't complain about a missing key.

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

Work around

Create an alias which restarts the emulator everytime it crashes.

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 &; em &> ~/emulator.log; done"

This is terrible, but what I'm currently working with.

map7
  • 5,096
  • 6
  • 65
  • 128
  • @Mohsinkazi No I don't use instant-run. It doesn't crash in the same app or time. I cannot find a pattern so far. – map7 Aug 25 '19 at 23:26
  • Possible duplicate of [IOException while requesting key: Invalid device key response](https://stackoverflow.com/questions/50168155/ioexception-while-requesting-key-invalid-device-key-response). – Martin Zeitler Aug 27 '19 at 19:04

4 Answers4

1

The reason is you don't have enough disk space in your desktop where you have installed the studio with emulator.Try cleaning some space and rerun the device or it this doesn't help try creating a new emulator.hope it helps.

karan sandhu
  • 171
  • 6
  • I have 551GB free, it's not the problem. – map7 Jul 17 '19 at 05:10
  • I have tried creating a Nexus9 AVD as well as a Pixel, Pixel2, & Pixel 3 AVD and they all have the same issue. They start and after about 30secs it crashes. – map7 Jul 17 '19 at 05:28
1

Your Bios might disabled the virtualization, you can enable it manually getting into bios and turn it on, bios is different in almost each device. Also the problem might be storage problem, no space, file corrupted or storage restricted by some program. Usually it will be Bios problem.

3Bady
  • 183
  • 3
  • 15
1

Try changing the Graphics to Software-GLES. It might be set to Automatic that takes hardware by default.

You will find the settings in Android Virtual Device Manager > Virtual Device Configuration> Emulated Performance> Software-GLES...

Samrat
  • 578
  • 1
  • 5
  • 20
  • I run with software graphics already using the flag on the command line ' -gpu guest' – map7 Aug 28 '19 at 05:24
  • can u please check the virtual device configuration once? I dont know about this flag. The thing is previously when I faced this kind of issue and after changing the graphics to software-gles, my issue was resolved. – Samrat Aug 28 '19 at 05:37
  • I don't run the full Android Studio on this machine only the sdk command line tools. Ref: https://developer.android.com/studio/run/emulator-acceleration#command-gpu I have tried all other options and the only thing which works on this computer is the 'guest'. On my notebook I use 'auto' and it crashes on there also. – map7 Aug 28 '19 at 05:50
  • check this: https://www.bram.us/2017/05/12/fix-for-the-android-emulator-crashing-during-launch/ also, there's a possibility that u might need to update ur drivers... also, try one thing, wipe off the data from the emulator and try running it...this is possibly not at all the solution but since u have tried many things so u can try this as well – Samrat Aug 28 '19 at 06:15
  • This worked for me. and those annoying warnings regarding GLES also goes away. but i decided to use hardware instead of software since it kind of crawls. hardware worked wonders :D – chitgoks May 24 '20 at 12:52
0

Try few of this methods. It might help you:

  • Emulator generally consume more RAM. May be you don't have enough memory to run.
  • Also the other reasons maybe : 1) Outdated graphics card drivers. 2) Older graphics cards.

  • There is an error :

    08-28 09:48:58.129 12476 12476 E memtrack: Couldn't load memtrack module (No such file or directory)

the Couldn't load memtrack module error could occur because of emulators configurations problems and, because your project contains many organization problems, it might help to give a fresh redesign.

  • I have configured the RAM at 3GB for the emulator. In reference to a redesign this problem happens even if I'm not running my application – map7 Aug 28 '19 at 05:24
  • If there is a newer version (compare to the version code defined in your manifest.xml) of the same Application in the target emulator, you will get error as you mentioned. **Couldn't load memtrack module (No such file or directory) failed to load memtrack module: -2** – rushabh sojitra Aug 28 '19 at 05:32