安卓模拟器分段错误

30

在命令行中运行它导致了分段错误:

$ emulator -avd nexus_s
Segmentation fault (core dumped)

然而,直接按照以下方式运行emulator-arm可以正常工作。

$ emulator-arm -avd nexus_s

我怀疑它正在尝试运行模拟器的MIPS或x86版本。 有没有一种方法可以配置模拟器启动哪个可执行文件?

所有这些都是在更新到Android SDK 17之后开始的。

添加-verbose标志会导致以下输出(我认为不会添加任何信息):

$ 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)

1
OS X?Linux?还是一些奇怪的平行宇宙版本的Windows,他们也采用了$命令提示符? - CommonsWare
Linux,具体来说是Ubuntu 12.04。 - grebulon
5
尝试在“emulator”命令行中添加“-v”,看看会输出到哪里。我在Ubuntu 11.10上使用R21 Android工具加载OpenGL驱动程序时遇到了“emulator”崩溃的问题——在b.android.com上有相关问题,解决方法是将那个OpenGL驱动程序重命名,这样Android就找不到它了。 - CommonsWare
在尝试使用命令行之前,AVD管理器会显示正在启动设备,但是窗口没有弹出。 - Nicolas
8个回答

24

在遵循CommonsWare的提示后,我终于找到了解决方案。重命名libOpenglRender.so文件后问题消失了。

mv tools/lib/libOpenglRender.so tools/lib/libOpenglRender.so.xxx

4
这样做确实可以让模拟器出现,但是它会输出以下错误信息:emulator: ERROR: Could not load OpenGLES emulation library: lib64OpenglRender.so: cannot open shared object file: No such file or directory。同时,模拟器还会警告说无法初始化OpenglES仿真器,使用软件渲染器。 - Chris.Zou
非常感谢!经过一周多的尝试,将<sdk-installation-folder>/tools/lib/中的所有lib*.文件重命名为lib.*.xxx后,模拟器终于启动了。我是对的,所有模拟器崩溃问题都与OpenGLES有关:https://code.google.com/p/android/issues/detail?id=33336和https://code.google.com/p/android/issues/detail?id=28601。 - warmth
将lib64OpenglRender.so重命名为lib64OpenglRender.so.xxx文件以适应64位系统。 - Amir Habibzadeh
1
当我尝试运行这个时,它需要很长时间才能加载AVD,并且像使用-gpu off选项一样运行,所以不知道它是否实际解决了问题...我们有什么办法可以在不使用有缺陷的OpenGL渲染器的情况下快速运行它? - Soroush
3
别犯和我一样愚蠢的错误,调用${ANDROID_HOME}/tools/emulator而不是${ANDROID_HOME}/emulator/emulator。第一个命令在我的机器上导致了段错误,我浪费了一些时间才意识到第二个路径是有效的。 - dheuvels

5

粘贴到 ~/.android/avd/.avd/config.ini 中。

hw.gpu.mode = swiftshader_indirect

这是我在我的情况下解决问题的方式。


4
在我的Ubuntu 12.04系统上,我通过确保在AVD配置中未启用“使用主机GPU”来解决了这个问题。

1
我在Ubuntu 20.04上遇到了同样的问题。将libOpenglRender.so重命名对我有用,但模拟器需要很长时间才能初始化。此外,我不得不重新安装Ubuntu(出于不同的原因),然后当我打开模拟器时,我开始收到“emulator:ERROR:Could not load OpenGLES emulation library”错误。
在进一步搜索这些问题之后,我发现问题出在视频驱动程序上。我使用了Nouveau的驱动程序,但切换到Nvidia驱动程序后,我不再需要保留libOpenglRender.so的重命名,并且现在模拟器可以快速初始化而不显示任何错误消息。
这是解决问题的驱动程序: enter image description here

0

通过Android Studio清除数据并冷启动设备解决了Ubuntu 16.04中的此问题。


0

我在Debian Wheezy上遇到了同样的问题。 Grebulon的答案对我有点用,但模拟器非常慢,所以我开始修复它(The Right Way (tm))。

在这种情况下,“Segmentation fault”可能表示OpenGL存在问题。 (请注意日志的最后一行是“emulator:Initializing hardware OpenGLES emulation support”)

在我的情况下,通过/var/log/Xorg.0.log搜索“GL”显示了一些NVidia GLX驱动程序(来自已经过时的视频卡)。鉴于我有AMD Radeon,我卸载了所有包含'nvidia'的软件包(列表:apt-get search nvidia | grep ^i),并安装了:

# apt-get install libgl1-fglrx-glx

重新启动模拟器后,出现了缺少 libOpenglRender.solibGL.so 的错误,我是这样解决的:
# 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

请注意,我的情况可能是独特的(问题始于我从NVidia转向AMD),但问题的根源可能相似(OpenGL)。我希望它能帮助到某些人。
更新:仍然无法工作,看起来我的驱动程序不支持OpenGL中的16位颜色...将进一步调查。

0

-1

输入命令

$ emulator-arm @nexus_s

希望这可以帮到你 :-)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接