我有一个无头Debian服务器,我曾经用于CI和测试。我不知道发生了什么,但它破了,所以我删除了整个SDK并从头开始。
我做了:
curl -s 'https://developer.android.com/studio/index.html#downloads' \
| grep -oP 'https?://dl.google.com/android/repository/sdk-tools-linux[^" ]+' \
| sort | uniq
./tools/bin/sdkmanager --update
yes | ./tools/bin/sdkmanager --licenses
./tools/bin/sdkmanager --install "platforms;android-27" "system-images;android-27;google_apis;x86"
echo no | ./tools/bin/avdmanager create avd --force --name avdname -k "system-images;android-27;google_apis;x86"
./emulator/emulator @avdname -no-window
它开始但在logcat它抱怨缺少Qemu:
01-09 23:15:19.278 4075 4075 D libEGL : Emulator has vendor provided software renderer, qemu.gles is set to 2.
01-09 23:15:19.282 4075 4075 D libEGL : loaded /vendor/lib/egl/libEGL_emulation.so
01-09 23:15:19.283 4075 4075 D libEGL : loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
01-09 23:15:19.288 4075 4075 D libEGL : loaded /vendor/lib/egl/libGLESv2_emulation.so
01-09 23:15:19.294 4075 4075 E : connect: failed with fd -1 errno 22
01-09 23:15:19.294 4075 4075 E : Failed to connect to host (QemuPipeStream)!!!
01-09 23:15:19.294 4075 4075 E EGL_emulation: Failed to establish connection with the host
01-09 23:15:19.294 4075 4075 W libEGL : eglInitialize(0xab2fb014) failed (EGL_SUCCESS)
01-09 23:15:19.295 4075 4075 I /system/bin/surfaceflinger: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
01-09 23:15:19.295 4075 4075 E EGL_emulation: tid 4075: eglGetConfigs(774): error 0x3001 (EGL_NOT_INITIALIZED)
01-09 23:15:19.295 4075 4075 E EGL_emulation: tid 4075: eglChooseConfig(796): error 0x3001 (EGL_NOT_INITIALIZED)
01-09 23:15:19.295 4075 4075 E EGL_emulation: tid 4075: eglGetConfigs(774): error 0x3001 (EGL_NOT_INITIALIZED)
01-09 23:15:19.295 4075 4075 E EGL_emulation: tid 4075: eglChooseConfig(796): error 0x3001 (EGL_NOT_INITIALIZED)
01-09 23:15:19.295 4075 4075 W SurfaceFlinger: no suitable EGLConfig found, trying a simpler query
01-09 23:15:19.296 4075 4075 E EGL_emulation: tid 4075: eglGetConfigs(774): error 0x3001 (EGL_NOT_INITIALIZED)
01-09 23:15:19.296 4075 4075 E EGL_emulation: tid 4075: eglChooseConfig(796): error 0x3001 (EGL_NOT_INITIALIZED)
01-09 23:15:19.296 4075 4075 F SurfaceFlinger: no suitable EGLConfig found, giving up
01-09 23:15:19.296 4075 4075 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 4075 (surfaceflinger), pid 4075 (surfaceflinger)
01-09 23:15:19.305 4086 4086 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
01-09 23:15:19.306 1592 1592 I /system/bin/tombstoned: received crash request for pid 4075
01-09 23:15:19.307 4086 4086 I crash_dump32: performing dump of process 4075 (target tid = 4075)
我有hw.gpu.enabled = false
,不确定它是否相关。
KVM很高兴:
$ ./tools/emulator -accel-check
accel:
0
KVM (version 12) is installed and usable.
accel
我不知道KVM是否是问题,或者GPU加速是否是其他问题。
有趣的是,这就像一个魅力:
./tools/bin/sdkmanager --install "system-images;android-26;google_apis;x86_64" "platforms;android-26"
echo no | ./tools/bin/avdmanager create avd --force --name avd26 -k "system-images;android-26;google_apis;x86_64"
./emulator/emulator @avd26 -no-window
是因为它是x86_64图像吗?因为API 27系统映像有问题吗?为什么API 27 b没有64位图像?
试试-gpu swiftshader
。这似乎解决了我的问题。
除了-no-window
param之外,尝试使用这些参数运行模拟器:
qemu -enable-kvm -snapshot
我最近在无头环境中启动模拟器时遇到了类似的问题,这有助于我解决它。系统映像版本无关紧要。