Android模拟器细分错误

gre*_*lon 22 android emulation android-virtual-device android-emulator

从命令行运行它会导致分段错误:

$ emulator -avd nexus_s
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)

但是,如下运行模拟器臂,工作正常.

$ emulator-arm -avd nexus_s
Run Code Online (Sandbox Code Playgroud)

我怀疑它正在尝试运行模拟器的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)
Run Code Online (Sandbox Code Playgroud)

gre*_*lon 24

按照CommonsWare的提示,我终于找到了解决方案.重命名libOpenglRender.so使问题消失.

mv tools/lib/libOpenglRender.so tools/lib/libOpenglRender.so.xxx
Run Code Online (Sandbox Code Playgroud)

  • 这确实使模拟器显示出来.但它输出以下错误消息:模拟器:错误:无法加载OpenGLES仿真库:lib64OpenglRender.so:无法打开共享对象文件:没有这样的文件或目录模拟器:警告:无法使用软件渲染器初始化OpenglES仿真. (4认同)
  • 不要犯和我一样的愚蠢错误,调用 `${ANDROID_HOME}/tools/emulator` 而不是 `${ANDROID_HOME}/emulator/emulator`。第一条路径在我的机器上出现了段错误,我浪费了一些时间才意识到第二条路径正在工作。 (3认同)

小智 5

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

hw.gpu.mode = swiftshader_indirect
Run Code Online (Sandbox Code Playgroud)

我的例子就是这样解决的。