解決ubuntu上在androidstudio中啟動emulator閃退的問題(1)


作者

彭東林

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

再次運行,發現可以成功運行了,而且沒有報任何錯誤,而且此時再在圖形界面里點擊啟動按鈕也是可以正常啟動模擬器的。

 

完。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM