
1.2.3 创建Android模拟器
Android模拟器可以实现在计算机上模拟移动设备中的Android环境,可以代替移动设备在计算机上安装并运行Android程序。接下来对创建智能手机Android模拟器的过程进行详细讲解。

1-4 创建模拟器
单击Android Studio工具栏中的【AVD Manager】按钮,进入【Your Virtual Devices】(你的虚拟设备)界面,如图1-26所示。

图1-26 【Your Virtual Devices】界面
在图1-26中,单击【Create Virtual Device】(创建虚拟设备)按钮,此时会进入【Select Hardware】(选择硬件)界面,如图1-27所示。

图1-27 【Select Hardware】界面
在图1-27中,其左侧是移动设备类型,中间是对应设备的名称、尺寸大小、分辨率和密度等信息,右侧是设备尺寸的预览图。选择Category类型为“Phone”,表示创建应用于手机项目开发的模拟器。然后选择模拟器的屏幕尺寸,在这里以Nexus 4模拟器为例,单击【Next】按钮,进入【System Image】(系统镜像)界面,如图1-28所示。
可根据自己的需求选择不同屏幕分辨率的模拟器。

图1-28 【System Image】界面
在图1-28中,左侧为推荐的Android系统镜像,右侧为选中的Android系统镜像对应的图标。有多个Android系统镜像可供选择,这里选择Q(Android 10.0)的系统版本进行下载,如图1-29和图1-30所示。

图1-29 【Component Installer】界面

图1-30 下载完成界面
在图1-30中,单击【Finish】按钮,再次进入【System Image】界面,如图1-31所示。选择刚下载的系统版本名称为Q的条目,单击【Next】按钮,进入【Android Virtual Device(AVD)】界面,如图1-32所示。

图1-31 再次进入【System Image】界面

图1-32 【Android Virtual Device(AVD)】界面
在图1-32中,可以对模拟器名称(AVD Name)进行重命名,然后单击【Finish】按钮,完成模拟器的创建。此时在【Your Virtual Devices】界面中会显示出刚创建的模拟器,如图1-33所示。可以根据开发需要,创建多个不同参数的模拟器。
在图1-33中,单击模拟器的启动按钮,模拟器就会像手机一样启动,启动完成后的界面如图1-34所示。到这里,手机Android模拟器就创建完成了,在后续开发过程中便可以使用该模拟器进行运行效果的测试。

图1-33 【Your Virtual Devices】界面

图1-34 模拟器界面