作者
彭东林
pengdonglin137@163.com
平台
Ubuntu14.04 64
androidstudio 2.3.3
现象
在创建好模拟器后,点击启动时,模拟器界面刚出来就闪退了
解决
由于是在图形界面点击启动的,看不到任何出错的log,所以我们需要使用命令行启动emulator的方式,这样会把出错的信息打印出来。
1、查看我们创建的模拟器的名字:
从上图看到模拟器的名字是: 32_QVGA_ADP2_API_25
2、找到android sdk中模拟器
对于我的机器,模拟器存放在/home/pengdonglin/disk_ext/Android_Latest/android_sdk/emulator
3、命令行运行模拟器
$./emulator64-x86 -avd 32_QVGA_ADP2_API_25 ./emulator64-x86: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./emulator64-x86) ./emulator64-x86: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: no version information available (required by ./emulator64-x86) ./emulator64-x86: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5: no version information available (required by ./emulator64-x86) ./emulator64-x86: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: no version information available (required by ./emulator64-x86) ./emulator64-x86: relocation error: ./emulator64-x86: symbol qt_version_tag, version Qt_5.7 not defined in file libQt5Core.so.5 with link time reference
上网搜索后,得到如下解决办法:
从网上下载Qt5.7的代码(qt-opensource-linux-x64-5.7.0.run),然后安装,将Qt5.7中含有上面的库的路径添加到环境变量中,我的是:
export LD_LIBRARY_PATH=/home/pengdonglin/Qt5.7.0/5.7/gcc_64/lib:$LD_LIBRARY_PATH
将上面的配置添加到.bashrc中,然后将其生效。
再次运行,得到如下出错信息:
$./emulator64-x86 -avd 32_QVGA_ADP2_API_25 sh: 1: glxinfo: not found Failed to open lib64EGL_translator: [lib64EGL_translator.so: cannot open shared object file: No such file or directory] gles2_dispatch_init: Could not load lib64GLES_V2_translator [lib64GLES_V2_translator.so: cannot open shared object file: No such file or directory] emulator: ERROR: Could not load OpenGLES emulation library [lib64OpenglRender]: lib64OpenglRender.so: cannot open shared object file: No such file or directory emulator: ERROR: Could not initialize OpenglES emulation, use '-gpu off' to disable it.
提示缺少上面的库,其实这些库就在模拟器所在的目录的lib64下,同样将该路径添加到环境变量中:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pengdonglin/disk_ext/Android_Latest/android_sdk/emulator/lib64
生效后,再次运行,又得到如下错误信息:
$./emulator64-x86 -avd 32_QVGA_ADP2_API_25 sh: 1: glxinfo: not found failed to create drawable getGLES2ExtensionString: Could not create GLES 2.x Pbuffer! Failed to obtain GLES 2.x extensions string! Could not initialize emulated framebuffer emulator: ERROR: Could not initialize OpenglES emulation, use '-gpu off' to disable it.
这里有两种解决办法:
第一种: 根据提示,在命令行后添加 -gpu off
第二种: 修改我们创建的模拟器配置,使用软件模拟GLES的方式:
如上图所示,选择Software-GLES 2.0
再次运行,发现可以成功运行了,而且没有报任何错误,而且此时再在图形界面里点击启动按钮也是可以正常启动模拟器的。
完。