【转】android开发中关于模拟器emulation的常见问题
2024-10-19 01:24:42
【转】android开发中关于模拟器emulation的常见问题
Trouble:
无法启动android模拟器,提示 XDM authorization key matches an existing client!
SDL init failure, reason is: No available video device
Oneway:
打开电脑的 Terminal 终端,
以当前图形界面用户的身份执行命令 xhost localhost 即可,如果想实现登录后自动执行这个命令,可以做以下操作
点开 Applicantions Menu -> Settings -> Session and Startup
在打开的选项中点击 Application Autostart
然后点击左下方的 Add 按钮,
设置Name的值为:xhost localhost
设置Description的值为:xhost localhost
设置Command的值为:xhost localhost
点击OK,点击Close,即可
Trouble:
无法启动android模拟器,提示 emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm). 或者提示
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: Could not open /dev/kvm :Permission denied
Oneway:
使用 root 权限执行以下三条命令后注销当前用户或者直接重启电脑即可
(本例子中当前登录图形界面的用户是 sman)
groupadd kvm
usermod -G kvm -a sman
echo 'KERNEL=="kvm",GROUP="kvm",MODE="0660"' >> /etc/udev/rules.d/androidUseKVM.rules
这三条命令的作用分别是:
#创建用户组kvm
#将用户sman添加到kvm用户组
#开机时自动赋予用户组kvm拥有0660的权限
Trouble:
无法启动android模拟器,提示 Android/Sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5_API_23 libGL error: failed to load driver: i965
libGL error: Try again with LIBGL_DEBUG=verbose for more details. failed to create drawable
getGLES1ExtensionString: Could not create GLES 1.x Pbuffer!
Failed to obtain GLES 1.x extensions string!
Could not initialize emulated framebuffer
Oneway:
根据提示在Terminal中申明环境变量并在Terminal中启动模拟器 export LIBGL_DEBUG=verbose; Android/Sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5_API_23 得到提示: libGL: OpenDriver: trying /usr/lib64/xorg/modules/dri/i965_dri.so
libGL error: failed to open drm device: Permission denied
libGL error: failed to load driver: i965
libGL: OpenDriver: trying /usr/lib64/xorg/modules/dri/swrast_dri.so
libGL: OpenDriver: trying /usr/lib64/xorg/modules/dri/i965_dri.so
libGL error: failed to open drm device: Permission denied
libGL error: failed to load driver: i965
libGL: OpenDriver: trying /usr/lib64/xorg/modules/dri/swrast_dri.so
failed to create drawable
getGLES1ExtensionString: Could not create GLES 1.x Pbuffer!
Failed to obtain GLES 1.x extensions string!
Could not initialize emulated framebufferSegmentation fault 先解决第一个错误,第一个错误是没有权限使用drm设备
于是使用groups命令检查当前用户是否存在于video用户组
[sman@mnxnm:~]$ groups
users plugdev vboxusers kvm
可以看到sman不属于video用户组 于是使用root权限将当前用户sman添加到video用户组
root@mnxnm:~# usermod -G video -a sman 注销当前用户再重新登录(必须重新登录,否则用户组改动不会生效)
登录后确认sman是否成功加入video用户组
[sman@mnxnm:~]$ groups
users video plugdev vboxusers kvm
可以看到sman成功加入video用户组 再启动Android studio,再通过Android Virtual Device Manager启动模拟器
看看错误有没有消除
如果提示NAND: could not write file /tmp/android-sman/emulator-7UY28S, File exists
则 rm /tmp/android-sman/emulator-* 后再试 OK,成功启动模拟器
Trouble:
android模拟器中DNS解析正常但无法ping通外网
Oneway:
这是正常现象,因为模拟器与PC之间的网络通信是通过TCP端口转发来实现的
而ping是ICMP数据包,没有端口,故模拟器无法将ping请求送出
但是是可以正常浏览网页的 所以不能用ping来测试模拟器是否能够联网,而是用网页浏览器来测试
Trouble:
android模拟器中安装调试apk时出错,提示 Application Installation Failed
Installation failed with message INSTALL_FAILED_CONTAINER_ERROR.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing. WARNING: Uninstalling will remove the application data! Do you want to uninstall the existing application?
Oneway:
方法一:adb root
adb shell rm /mnt/secure/asec/smdl* 方法二:将项目源文件 AndroidManifest.xml 中的
android:installLocation="preferExternal"
修改成
android:installLocation="auto"
即可
最新文章
- Android关于listView的BaseAdapter以及getView的三级优化
- Quartz2D复习(一)--- 基础知识 / 绘制线段圆弧 / 图片水印 / 截图
- Git 怎样保证fork出来的project和原project(上游项目)同步更新
- Struts2 的验证
- javascript笔记2-引用类型
- Scala List
- jquery中json数据转换为字典
- 【HDOJ】3127 WHUgirls
- mac安装office2011,提示无法打开文件Normal.dotm,因为内容有错误
- KMP 知识点总结
- ubuntu下安装nagios
- Tomcat启动:Container StandardContext[] has not been started
- bootstrap boosting bagging辨析
- django系列 1 :python+django环境搭建 +mac提示找不到manage.py命令
- kafka与zookeeper
- 180400之pycharm快捷方式汇总
- Libreoffice 各类文件转换的filtername
- Arduino 433 自定义发射
- Faster RCNN代码理解(Python)
- Android Bug:Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams;
热门文章
- 非原生APP开发中可以用到的JQ插件
- 为什么要for循环以及for循环的流程
- Pro/Engineer wildfire 5.0 野火版系列下载及安装方法
- Javascript 风格向导
- 宣布发布全新的 Windows Azure 缓存预览版
- HDU 1512 Monkey King(左偏树+并查集)
- ubuntu12.04下 安装虚拟主机
- android之PackageManager简单介绍
- windows下搭建apache+php+mysql
- BootStrap 智能表单系列 首页 (持续更新中...)