ubuntu上在androidstudio中启动emulator闪退怎么办

这篇文章主要介绍了ubuntu上在androidstudio中启动emulator闪退怎么办,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

一、查看模拟器的信息
二、命令行运行模拟器

平台

Ubuntu14.04 64

现象

在AndrodStudio中点击模拟器的启动按钮后,模拟器界面弹出后,又立刻闪退。

解决

一、查看模拟器的信息

ubuntu上在androidstudio中启动emulator闪退怎么办

从上面可以看到模拟器的存放路径以及名称:

路径:/home/pengdonglin/.android/avd/4_WVGA_Nexus_S_API_24.avd

名称:4_WVGA_Nexus_S_API_24

架构:x86_64

二、命令行运行模拟器

在androidsdk的路径下面运行下面的命令:

./emulator/qemu/linux-x86_64/qemu-system-x86_64 -avd 4_WVGA_Nexus_S_API_24
此时出现了错误:

emulator: WARNING: encryption is off
WARNING: The Mesa software renderer is deprecated. Use Swiftshader (-gpu swiftshader) for software rendering.
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
warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]
warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]
emulator: emulator window was out of view and was recentered
emulator: ERROR: Could not initialize OpenglES emulation, use '-gpu off' to disable it.

从提示中有两种解决办法:

1、设置 -gpu swiftshader

2、设置 -gpu off

在运行模拟器的时候,加入上面任意一个,都可以解决问题,但是最终我们并不是从命令行运行模拟器,所以我们得把这上面的配置写到模拟器的启动配置文件中。

从模拟器的配置信息看:

ubuntu上在androidstudio中启动emulator闪退怎么办

这里已经设置了软件GLES 2.0,所以这里就需要在配置文件中修改模拟器的配置了,配置文件的路径:

~/.android/avd/4_WVGA_Nexus_S_API_24.avd/config.ini

下面是这个文件中关于GPU的配置:

hw.gps=yes
hw.gpu.enabled=yes
hw.gpu.mode=mesa

解决方法1:

hw.gpu.enabled=no
hw.gpu.mode=mesa

解决方法2:

hw.gpu.enabled=yes
hw.gpu.mode=swiftshader

使用上面的任意一个,模拟器都可以运行:

ubuntu上在androidstudio中启动emulator闪退怎么办

感谢你能够认真阅读完这篇文章,希望小编分享的“ubuntu上在androidstudio中启动emulator闪退怎么办”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注行业资讯频道,更多相关知识等着你来学习!