当前位置: 首页 > news >正文

Android Studio 虚拟机启动失败/没反应,排查原因。提供一种排查方式。

我自己用的Android Studio 启动虚拟机去调试,启动了之后没反应,整的我手足无措,因为Android Studio本身没有报任何错误提示。本篇文章给出一种调试的方法。

一、Android Studio 虚拟机的组成

1、emulator 程序

  emulator是工具,负责运行镜像文件,类似于汽车的发动机。
程序目录:C:\Users\用户名\AppData\Local\Android\Sdk\emulator

2、system-images

  system-images 是内容,提供 Android 系统,类似汽车的车身。
镜像目录:C:\Users\用户名\AppData\Local\Android\Sdk\system-images

3、AVD 配置

  AVD是一个虚拟机的状态记录,记录了当前虚拟机的实时状况,类似汽车的行车记录仪。
AVD默认目录:C:\Users\用户名\.android\avd。为了节省C盘本身的空间,AVD的所在目录是可以修改的,增加一个Windows的用户属性 ANDROID_AVD_HOME 即可:重启生效。
在这里插入图片描述
总结:当你创建并打开一个虚拟机时,Studio 会选择对应的 system-image。在 ~/.android/avd/ 下创建 userdata、cache、sdcard。调用 emulator 程序加载系统镜像启动虚拟机。 下载了虚拟机之后,单单在Android Studio中删除也是删不干净的,必须把上述的三个部分都删除掉。

二、排查问题

  找到emulator的目录,按如下操作打开命令行:
在这里插入图片描述

1、emulator -list-avds 列出虚拟机

在这里插入图片描述

2、emulator -avd Television_1080p_API_34 -verbose 启动特定虚拟机

  -verbose用来打印具体的启动信息,这里就可以知道虚拟机为什么启动失败了,我的报错如下:

C:\Users\htc-003\AppData\Local\Android\Sdk\emulator>emulator -avd Television_1080p_API_34 -verbose
INFO    | Storing crashdata in: C:\Users\htc-003\AppData\Local\Temp\\AndroidEmulator\emu-crash-34.2.14.db, detection is enabled for process: 12620
INFO    | Android emulator version 34.2.14.0 (build_id 11834374) (CL:N/A)
DEBUG   | Current emulator version 34.2.14 is the same as the required version 34.2.14.
INFO    | Found AVD name 'Television_1080p_API_34'
INFO    | Found AVD target architecture: x86
INFO    | argv[0]: 'emulator'; program directory: 'C:\Users\htc-003\AppData\Local\Android\Sdk\emulator'
INFO    | Found systemPath C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\
INFO    | emuDirName: 'C:\Users\htc-003\AppData\Local\Android\Sdk\emulator'
INFO    | Found systemPath C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\
INFO    | Probing for C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\\kernel-ranchu-64: file exists
INFO    | try dir C:\Users\htc-003\AppData\Local\Android\Sdk\emulator
INFO    | Trying emulator path 'C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe'
INFO    | Found target-specific 64-bit emulator binary: C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe
INFO    | Adding library search path: 'C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\lib64'
INFO    | Adding library search path: 'C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\lib64\gles_swiftshader'
INFO    | Quoted param: [C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe]
INFO    | Quoted param: [-avd]
INFO    | Quoted param: [Television_1080p_API_34]
INFO    | Quoted param: [-verbose]
DEBUG   | emulator: Running :C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe
DEBUG   | qemu backend: argv[00] = "C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe"
DEBUG   | qemu backend: argv[01] = "-avd"
DEBUG   | qemu backend: argv[02] = "Television_1080p_API_34"
DEBUG   | qemu backend: argv[03] = "-verbose"
DEBUG   | Concatenated backend parameters:  C:\Users\htc-003\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe -avd Television_1080p_API_34 -verbose
INFO    | Storing crashdata in: C:\Users\htc-003\AppData\Local\Temp\\AndroidEmulator\emu-crash-34.2.14.db, detection is enabled for process: 4820
INFO    | Duplicate loglines will be removed, if you wish to see each individual line launch with the -log-nofilter flag.
DEBUG   | autoconfig: -skin tv_1080p
DEBUG   | autoconfig: -skindir C:\Users\htc-003\AppData\Local\Android\Sdk\skins\
DEBUG   | querying file version info API...
DEBUG   | found kernelbase.dll
DEBUG   | GetFileVersionInfoSizeW found. On Windows 10?
DEBUG   | GetFileVersionInfoW found. On Windows 10?
DEBUG   | VerQueryValueW found. Can query file versions
DEBUG   | queryFileVersionInfo: path not found: amdvlk64.dll
DEBUG   | querying file version info API...
DEBUG   | queryFileVersionInfo: path not found: amdvlk32.dll
DEBUG   | querying file version info API...
DEBUG   | autoconfig: -kernel C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\\kernel-ranchu-64
DEBUG   | Target arch = 'x86'
DEBUG   | Auto-config: -qemu -cpu qemu32
DEBUG   | Auto-detect: Kernel image requires new device naming scheme.
DEBUG   | Auto-detect: Kernel does not support YAFFS2 partitions.
DEBUG   | autoconfig: -ramdisk C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\\ramdisk.img
DEBUG   | Using initial system image: C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\\system.img
DEBUG   | Using initial vendor image: C:\Users\htc-003\AppData\Local\Android\Sdk\system-images\android-34\google-tv\x86\\vendor.img
DEBUG   | autoconfig: -data D:\.android\avd\Television_1080p_API_34.avd\userdata-qemu.img
DEBUG   | autoconfig: -initdata D:\.android\avd\Television_1080p_API_34.avd\userdata.img
DEBUG   | autoconfig: -cache D:\.android\avd\Television_1080p_API_34.avd\cache.img
DEBUG   | autoconfig: -sdcard D:\.android\avd\Television_1080p_API_34.avd\sdcard.img
DEBUG   | Physical RAM size: 2048MB
DEBUG   | VM heap size 48MB is below hardware specified minimum of 512MB,setting it to that value
DEBUG   | System image is read only
INFO    | IPv4 server found: 114.114.114.114
INFO    | Ignore IPv6 address: e879:378b:4902:0:b06c:378b:4902:0
INFO    | Ignore IPv6 address: e879:378b:4902:0:b06c:378b:4902:0 (2x)
INFO    | Ignore IPv6 address: d87f:378b:4902:0:b06c:378b:4902:0
INFO    | Ignore IPv6 address: d87f:378b:4902:0:b06c:378b:4902:0 (2x)
INFO    | Ignore IPv6 address: d085:378b:4902:0:b06c:378b:4902:0
INFO    | Ignore IPv6 address: d085:378b:4902:0:b06c:378b:4902:0 (2x)
INFO    | Ignore IPv6 address: c88b:378b:4902:0:b06c:378b:4902:0
INFO    | Ignore IPv6 address: c88b:378b:4902:0:b06c:378b:4902:0 (2x)
DEBUG   | Found 1 DNS servers:
DEBUG   |       114.114.114.114
DEBUG   | Starting hostapd main loop.
DEBUG   | trying to load skin file 'C:\Users\htc-003\AppData\Local\Android\Sdk\skins\\tv_1080p\layout'
WARNING | Failed to process .ini file D:\.android\avd\Television_1080p_API_34.avd\quickbootChoice.ini for reading.
HAXM is deprecated and not supported by Intel any more. Please download and install Android Emulator Hypervisor Driver for AMD Processors, which also supports Intel Processors. Installing from SDK Manager is comming soon.
DEBUG   | CPU Acceleration: working
DEBUG   | CPU Acceleration status: HAXM version 7.6.5 (4) is installed and usable.
DEBUG   | handleCpuAcceleration: feature check for hvf
DEBUG   | Bluetooth requested by guest
DEBUG   | started modem simulator host server at port: 60617
INFO    | Critical:
INFO    | Warning:
INFO    | Warning:  (6x)
INFO    | Crash reports will be automatically uploaded to: https://clients2.google.com/cr/report
library_mode host gpu mode host
DEBUG   | GPU emulation enabled using 'host' mode
INFO    | Initializing hardware OpenGLES emulation support
android_startOpenglesRenderer: gpu infoGPU #1Make: 8086Model: Intel(R) UHD Graphics 730Device ID: 4682
I1009 13:56:04.129026    6580 HealthMonitor.cpp:279] HealthMonitor disabled.
DEBUG   | create display 0
DEBUG   | setDisplayPose 0 x 0 y 0 w 1920 h 1080 dpi 0
added library vulkan-1.dll
INFO    | Attempting to send crashreport 84fc2ae1-2764-48e9-9e90-db497712445e to https://clients2.google.com/cr/report
createGlobalVkEmulation:995 Selecting Vulkan device: Intel(R) UHD Graphics 730
initialize: Supports id properties, got a vulkan device UUID
I1009 13:56:04.289707    6580 VkCommonOperations.cpp:1276] Initializing VkEmulation features:
I1009 13:56:04.289798    6580 VkCommonOperations.cpp:1277]     glInteropSupported: true
I1009 13:56:04.289838    6580 VkCommonOperations.cpp:1278]     useDeferredCommands: true
I1009 13:56:04.289874    6580 VkCommonOperations.cpp:1280]     createResourceWithRequirements: true
I1009 13:56:04.289910    6580 VkCommonOperations.cpp:1281]     useVulkanComposition: false
I1009 13:56:04.289945    6580 VkCommonOperations.cpp:1282]     useVulkanNativeSwapchain: false
I1009 13:56:04.289982    6580 VkCommonOperations.cpp:1283]     enable guestRenderDoc: false
I1009 13:56:04.290016    6580 VkCommonOperations.cpp:1284]     ASTC LDR emulation mode: 2
I1009 13:56:04.290057    6580 VkCommonOperations.cpp:1285]     enable ETC2 emulation: true
I1009 13:56:04.290125    6580 VkCommonOperations.cpp:1286]     enable Ycbcr emulation: false
I1009 13:56:04.290183    6580 VkCommonOperations.cpp:1287]     guestUsesAngle: false
I1009 13:56:04.290218    6580 VkCommonOperations.cpp:1288]     useDedicatedAllocations: false
E1009 13:56:04.290417    6580 VkCommonOperations.cpp:3570] Failed to initialize memory type index test ColorBuffer.
F1009 13:56:04.290475    6580 VkCommonOperations.cpp:1325] FATAL in initVkEmulationFeatures, err code: 4300000000: Failed to find memory type for ColorBuffers.C:\Users\htc-003\AppData\Local\Android\Sdk\emulator>

  关机的两句报错如下:

E1009 13:56:04.290417    6580 VkCommonOperations.cpp:3570] Failed to initialize memory type index test ColorBuffer.
F1009 13:56:04.290475    6580 VkCommonOperations.cpp:1325] FATAL in initVkEmulationFeatures, err code: 4300000000: Failed to find memory type for ColorBuffers.

  VkCommonOperations.cpp → Vulkan GPU 渲染初始化。说明虚拟机在初始化 Vulkan 图形加速时失败,很可能是英特尔的集成显卡驱动不兼容当前的渲染模式。尝试用软件渲染代替GPU渲染。

3、emulator -avd Television_1080p_API_34 -gpu swiftshader_indirect -verbose 使用软件渲染方式打开虚拟机

  用这种方式去启动立马成功了。除了上述这种用命令的方式,还可以在添加虚拟机时,指定图像渲染方式,如下:
在这里插入图片描述
有些虚拟机添加的时候Graphics根本不能选,只有默认的Automatic,这个时候就只能去改配置文件了,找到自己的avd目录对应的虚拟机,找到config.ini文件,我的如下:D:.android\avd\Pixel_8_Pro_API_34.avd\config.ini
在这里插入图片描述
修改hw.gpu.mode为swiftshader_indirect即可。

三、总结

  本文提供了一种排查虚拟机启动失败的方法,主要是要了解Android Studio启动一个虚拟机是怎样的流程,包含那三个部分,以及三个部分的作用。

http://www.dtcms.com/a/462510.html

相关文章:

  • 网站设计需要考虑的基本原则建房子找哪个网站设计
  • C#基础11-常用类
  • 流媒体 网站开发网站制作排版
  • 那个网站适合学生做兼职广州网站车管所
  • 公司内部网站系统微信小程序直播开通条件
  • 个人备案做门户网站wordpress 视频
  • 网站开发公司地址免费引流软件下载
  • 网站中的游戏是怎么做的濮阳新闻综合频道回看
  • 在springBoot项目如何进行视频压缩
  • 电商平台下载seo网站优化平台
  • Java面试常用算法api速刷
  • aspnet东莞网站建设抚州购物网站开发设计
  • 东营专业网站建设天河建设网站企业
  • 烤肉自助餐网站建设wordpress视频主题模板下载地址
  • 可以下载的网站模板资产管理公司注册条件
  • Jenkins 使用容器运行自动化任务详细文档
  • 闵行网站建设公司韩国服务器ip地址
  • 丝杆模组从结构到应用,有哪些核心类型?
  • 字节面试题:MSE的优化
  • 建设通网站会员共享密码佛山外贸网站制作
  • 哪个素材网站免费免费行情网站app斗印
  • 聚类的数据集
  • ElasticSearch八股
  • 梦中的统计:C++实现与算法分析(洛谷P1554)
  • 鸿蒙9568322问题
  • 破解工地防盗难题:如何利用EasyCVR实现视频监控统一管理?
  • 网站注册协议模板wordpress 调用摘要
  • 电商商拍革命!2025年AI工具实战测评
  • javascript中的三角关系
  • 网站的总体风格包括石家庄 网站开发