Android emulator segmentation fault
Asked Answered
S

11

31

Running it from the command line resulted in a segmentation fault:

$ emulator -avd nexus_s
Segmentation fault (core dumped)

However, running emulator-arm directly as follows, works fine.

$ emulator-arm -avd nexus_s

I suspect it's trying to run the mips or x86 version of the emulator. Is there a way to configure the emulator which executable to start?

All this started after updating to android sdk 17.

Adding the -verbose flag gives the following output (which I don't think adds any info):

$ emulator -verbose -avd nexus_s
emulator: found SDK root at /opt/sdk
emulator: Android virtual device file at: /home/grebulon/.android/avd/nexus_s.ini
emulator: virtual device content at /home/grebulon/.android/avd/nexus_s.avd
emulator: virtual device config file: /home/grebulon/.android/avd/nexus_s.avd/config.ini
emulator: using core hw config path: /home/grebulon/.android/avd/nexus_s.avd/hardware-qemu.ini
emulator: Found AVD target API level: 17
emulator: 'magic' skin format detected: 480x800
emulator: autoconfig: -skin 480x800
emulator: autoconfig: -skindir (null)
emulator: keyset loaded from: /home/grebulon/.android/default.keyset
emulator: found magic skin width=480 height=800 bpp=16

emulator: autoconfig: -kernel /opt/sdk/system-images/android-17/armeabi-v7a//kernel-qemu
emulator: autoconfig: -ramdisk /opt/sdk/add-ons/addon-google_apis-google-17/images/armeabi-v7a//ramdisk.img
emulator: Using initial system image: /opt/sdk/add-ons/addon-google_apis-google-17/images/armeabi-v7a//system.img
emulator: autoconfig: -data /home/grebulon/.android/avd/nexus_s.avd/userdata-qemu.img
emulator: autoconfig: -initdata /home/grebulon/.android/avd/nexus_s.avd/userdata.img
emulator: autoconfig: -cache /home/grebulon/.android/avd/nexus_s.avd/cache.img
emulator: Physical RAM size: 343MB

Content of hardware configuration file:
  hw.cpu.arch = arm
  hw.cpu.model = cortex-a8
  hw.ramSize = 343
  hw.screen = touch
  hw.mainKeys = yes
  hw.trackBall = no
  hw.keyboard = no
  hw.keyboard.lid = no
  hw.keyboard.charmap = qwerty2
  hw.dPad = no
  hw.gsmModem = yes
  hw.gps = yes
  hw.battery = no
  hw.accelerometer = yes
  hw.audioInput = yes
  hw.audioOutput = yes
  hw.sdCard = yes
  disk.cachePartition = yes
  disk.cachePartition.path = /home/grebulon/.android/avd/nexus_s.avd/cache.img
  disk.cachePartition.size = 66m
  hw.lcd.width = 480
  hw.lcd.height = 800
  hw.lcd.depth = 16
  hw.lcd.density = 240
  hw.lcd.backlight = yes
  hw.gpu.enabled = yes
  hw.camera.back = none
  hw.camera.front = none
  vm.heapSize = 32
  hw.sensors.proximity = yes
  hw.sensors.magnetic_field = yes
  hw.sensors.orientation = yes
  hw.sensors.temperature = yes
  kernel.path = /opt/sdk/system-images/android-17/armeabi-v7a//kernel-qemu
  kernel.parameters =  android.checkjni=1
  disk.ramdisk.path = /opt/sdk/add-ons/addon-google_apis-google-17/images/armeabi-v7a//ramdisk.img
  disk.systemPartition.initPath = /opt/sdk/add-ons/addon-google_apis-google-17/images/armeabi-v7a//system.img
  disk.systemPartition.size = 200m
  disk.dataPartition.path = /home/grebulon/.android/avd/nexus_s.avd/userdata-qemu.img
  disk.dataPartition.size = 209m
  avd.name = nexus_s
.
QEMU options list:
emulator: argv[00] = "/opt/sdk/tools/emulator64-arm"
emulator: argv[01] = "-android-hw"
emulator: argv[02] = "/home/grebulon/.android/avd/nexus_s.avd/hardware-qemu.ini"
Concatenated QEMU options:
 /opt/sdk/tools/emulator64-arm -android-hw /home/grebulon/.android/avd/nexus_s.avd    /hardware-qemu.ini
emulator: registered 'boot-properties' qemud service
emulator: nand_add_dev: system,size=0xc800000,initfile=/opt/sdk/add-ons/addon-google_apis-google-17/images/armeabi-v7a//system.img
emulator: mapping 'system' NAND image to /tmp/android-grebulon/emulator-RSuUtb
emulator: rounding devsize up to a full eraseunit, now c810000

emulator: nand_add_dev: userdata,size=0xd100000,file=/home/grebulon/.android/avd/nexus_s.avd/userdata-qemu.img
emulator: rounding devsize up to a full eraseunit, now d116000

emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'dalvik.vm.heapsize' = '32m'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '240'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '1'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'none'
emulator: nand_add_dev: cache,size=0x4200000,file=/home/grebulon/.android/avd/nexus_s.avd/cache.img
emulator: Initializing hardware OpenGLES emulation support
Segmentation fault (core dumped)
Standoffish answered 21/12, 2012 at 22:3 Comment(4)
OS X? Linux? Some strange parallel-universe version of Windows where they too adopted the $ command prompt?Spectrohelioscope
Linux, ubuntu 12.04 to be specific.Standoffish
Try adding -v to the emulator command line and see where it dumps. I had a problem with emulator on the R21 Android tools crashing when trying to load an OpenGL driver on Ubuntu 11.10 -- there's an issue about it on b.android.com, where the workaround is to rename that OpenGL driver so Android can't find it.Spectrohelioscope
Before I tried the command-line, the AVD manager would say it is starting the device, but no window would show up.Monde
S
24

I finally found a solution after following CommonsWare's tip. Renaming libOpenglRender.so made the problem go away.

mv tools/lib/libOpenglRender.so tools/lib/libOpenglRender.so.xxx
Standoffish answered 29/12, 2012 at 14:17 Comment(5)
This does make the emulator show up. but It outputs the following error message: emulator: ERROR: Could not load OpenGLES emulation library: lib64OpenglRender.so: cannot open shared object file: No such file or directory emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.Zachar
THANK YOU VERY MUCH!!! After more than a week trying everything here and there renaming all the lib*.* files from <sdk-installation-folder>/tools/lib/ to lib*.*.xxx made the emulator to start. I was right, all the emulator crashing issue was related to OpenGLES: code.google.com/p/android/issues/detail?id=33336 & code.google.com/p/android/issues/detail?id=28601Bon
For 64 bit rename the lib64OpenglRender.so to lib64OpenglRender.so.xxx file.Eudosia
When I try this it takes for ever to load the AVD and it's like running it with the -gpu off option so don't know if it actually solves the problem... anyway we can get it to run fast without using the buggy openGL renderer?Hygienics
Don't make the same stupid mistake as me, calling ${ANDROID_HOME}/tools/emulator instead of ${ANDROID_HOME}/emulator/emulator. The first one segfaulted on my machine and I wasted some time before I realized the second path was working.Psychopharmacology
E
5

Paste to ~/.android/avd/.avd/config.ini

hw.gpu.mode = swiftshader_indirect

I solved it this way in my case.

Equilibrate answered 15/7, 2020 at 9:54 Comment(1)
weird. I tried this and some variations of the pathname, but the option hw.gpu.mode = host never had success while -gpu host worked (the file didn't exist on my machine, I even had to create the .avd directory)Gerius
R
4

On my Ubuntu 12.04 system, I solved this problem by making sure "Use Host GPU" was not turned on in the AVD configuration.

Recoup answered 11/11, 2013 at 12:37 Comment(0)
U
2

Old question, but since it's coming up when I search for this error, I figured I'd post my solution.

I ran my emulator from the terminal using emulator -avd Pixel_7_API_31_S_ -gpu off to test to make sure it was a GPU issue. In doing so, I noticed that the terminal output was giving me warnings about my emulator needing to be updated. Updating fixed the overall issue.

  1. Go to Tools > SDK Manager, then to the SDK Tools tab.
  2. Find Android Emulator in the list and change it to a checkmark (mine was a dash).
  3. Click the OK button.
Urethrectomy answered 15/1, 2024 at 22:27 Comment(1)
This worked for me. I hadn't change my AVD in a while (~2yrs), and had to update the emulator for the newest AVD / API.Stinkpot
S
1

I had the same problem on Ubuntu 20.04. Renaming libOpenglRender.so was working for me, but the emulator was taking forever to initialize. Also, I had to reinstall Ubuntu (for different reasons), and then I started getting the emulator: ERROR: Could not load OpenGLES emulation library error when opening the emulator.

After searching more about those issues, I found out that the problem was with the video driver. I was using the Nouveau's, and after changing to an Nvidia driver, I no longer had to keep libOpenglRender.so renamed, and now the emulator initializes very fast without showing any error message.

This is the driver that fixed the issue: enter image description here

Sadler answered 13/3, 2021 at 12:53 Comment(0)
C
1

What helped me was to copy the libtcmalloc_minimal.so.4 file to the SDK directory:

cp /usr/lib/libtcmalloc_minimal.so.4 emulator/lib64/libtcmalloc_minimal.so.4
Churchill answered 5/3, 2024 at 13:35 Comment(0)
A
0

I had the same problem on Debian Wheezy. The grebulon's answer kind-of worked for me, however the emulator was sloooooow so I set out to fix it The Right Way (tm).

In this case Segmentation fault probably indicates problems with OpenGL. (note that last line of log is "emulator: Initializing hardware OpenGLES emulation support")

In my case, searching for 'GL' through /var/log/Xorg.0.log showed some NVidia GLX driver (from old video card which went to digital heaven). Given the fact that I have AMD Radeon I uninstalled every package with 'nvidia' in it (list: apt-get search nvidia | grep ^i) and installed:

# apt-get install libgl1-fglrx-glx

After reboot emulator complained about missing libOpenglRender.so and libGL.so, which I solved like this:

# echo "/opt/adt/sdk/tools/lib" > /etc/ld.so.conf.d/android_stuff.conf
# ldconfig
# cd /opt/adt/sdk/tools/lib
# ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 libGL.so

Note that my situation is probably unique (problems started when I went from NVidia to AMD), but the root of the problem is probably similar (OpenGL). I hope it helps someone.

UPDATE: still doesn't work, it looks like my drivers do not support 16-bit colors in OpenGL... will investigate further.

Antoneantonella answered 17/1, 2014 at 20:28 Comment(0)
B
0

If you don't find the answer here you should subscribe to:

  1. Issue 34233: Emulator start produces segmentation fault after upgrading to r20
  2. Issue 55325: Emulator crashing with segfault
  3. Issue 20952: Emulator segfault on startup (unrelated to audio)

There you will receive updates about this issue and find some workarounds (like renaming lib*.* files).

Bon answered 29/1, 2014 at 17:12 Comment(0)
P
0

wiping data and cold booting device through android studio solved this issue in ubuntu 16.04

Poynter answered 16/1, 2019 at 8:51 Comment(0)
G
0

I had this problem in an lxc environment. After getting

./Android/Sdk/emulator/emulator @Pixel_3a_API_34_extension_level_7_x86_64 
Segmentation fault (core dumped)

I had success with option

./Android/Sdk/emulator/emulator @Pixel_3a_API_34_extension_level_7_x86_64 -no-qt

This is a headless mode (no window at all, so don't be surprised). It showed me that the problem was in the graphical representation.

I then found that -gpu auto, -gpu swiftshader_indirect and -gpu guest failed, while -gpu host worked.

So, the final line on my machine is:

./Android/Sdk/emulator/emulator @Pixel_3a_API_34_extension_level_7_x86_64 -gpu host

To make this persistent, I had to add it to ~/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd/config.ini, thanks to DARUMA:

$ tail ~/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd/config.ini 

hw.gpu.mode = host
Gerius answered 19/12, 2023 at 14:6 Comment(0)
E
-2

Type command

$ emulator-arm @nexus_s

Hope this helps :-)

Enliven answered 16/11, 2013 at 19:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.