[英]Android emulator segmentation fault
從命令行運行它會導致分段錯誤:
$ 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)
在遵循 CommonsWare 的提示后,我終於找到了解決方案。 重命名 libOpenglRender.so 使問題消失。
mv tools/lib/libOpenglRender.so tools/lib/libOpenglRender.so.xxx
在我的 Ubuntu 12.04 系統上,我通過確保在 AVD 配置中沒有打開“使用主機 GPU”來解決這個問題。
粘貼到 ~/.android/avd/.avd/config.ini
hw.gpu.mode = swiftshader_indirect
在我的情況下,我是這樣解決的。
我在 Debian Wheezy 上遇到了同樣的問題。 grebulon 的答案對我有用,但是模擬器太慢了,所以我開始以正確的方式(tm)修復它。
在這種情況下, Segmentation fault
可能表示 OpenGL 存在問題。 (請注意,日志的最后一行是“模擬器:初始化硬件 OpenGLES 模擬支持”)
就我而言,通過/var/log/Xorg.0.log
搜索“GL”顯示了一些 NVidia GLX 驅動程序(來自進入數字天堂的舊顯卡)。 鑒於我有 AMD Radeon,我卸載了每個包含“nvidia”的軟件包(列表: apt-get search nvidia | grep ^i
)並安裝:
# apt-get install libgl1-fglrx-glx
重啟模擬器后抱怨缺少libOpenglRender.so
和libGL.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 位顏色......將進一步調查。
如果您在此處找不到答案,請訂閱:
在那里您將收到有關此問題的更新並找到一些解決方法(例如重命名 lib*.* 文件)。
在 ubuntu 16.04 中通過 android studio 擦除數據和冷啟動設備解決了這個問題
我在 Ubuntu 20.04 上遇到了同樣的問題。 重命名 libOpenglRender.so 對我有用,但模擬器需要永遠初始化。 另外,我不得不重新安裝 Ubuntu(出於不同的原因),然后我開始獲取emulator: ERROR: Could not load OpenGLES emulation library
打開模擬器時emulator: ERROR: Could not load OpenGLES emulation library
錯誤。
在搜索了有關這些問題的更多信息后,我發現問題出在視頻驅動程序上。 我正在使用 Nouveau 的,在更改為 Nvidia 驅動程序后,我不再需要重命名 libOpenglRender.so,現在模擬器初始化非常快而不會顯示任何錯誤消息。
.android/avd/{avd name}.ini文件中的以下編輯為我解決了這個問題。
hw.gpu.mode=auto
hw.gpu.enabled = no
鍵入命令
$ 模擬器臂@nexus_s
希望這可以幫助 :-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.