In this video, you’ll see how to use the device manager in Android Studio to create a new virtual device. You’ll walk through the process of setting up a new emulator, and you’ll see how to control the emulator through the Running Devices window.
The device manager in Android Studio is the tool you’ll use to create emulators. Find the device manager icon on the far right toolbar of Android Studio. Click the device manager icon to open the device manager window.
The device manager displays a list of physical and virtual devices that have been connected or created in Android Studio. If you’ve not yet created or connected an Android device, the list will be empty. To create a new emulator, click the plus icon in the device manager, and you’ll see the virtual device configuration screen.
The virtual device configuration screen will show you a list of categories on the left and a set of preconfigured devices on the right. The list of devices contains columns that display the size, resolution, and density that each configuration will come with. One of the columns you should be aware of is the Play Store column.
If you see a Google Play icon in the column, it means that the emulator will have the Google Play Store app configured and access to Google Play services. This will be important to know when you need an emulator with Google Play services capability. If you can’t find a device configuration that fits your needs, you can import hardware profiles, create a new custom hardware profile, or clone an existing profile directly from this screen.
You’ll be creating a Pixel 7 emulator, but for now, click on New Hardware Profile and take a peek at what it would look like to create a custom emulator. You’ll see the hardware profile configuration window. This window allows you to create a fully customized emulator. Scroll down the window on the left to see all the configurations you can change in your emulator. Configurations include device type, screen size, resolution, memory, and hardware accessories. Click cancel to go back to the virtual device hardware configuration screen.
Select the phone category on the left panel, and you’ll see a list of phones on the right panel. The list is a set of phones that match the hardware profile and characteristics of devices that are available in the market. To emulate a Pixel 7 device, select Pixel 7 and click Next.
The system image window will be displayed. It gives you the ability to select a system image for your emulator. The list of system images is grouped by tabs. System images are composed of an API Level, ABI, and Target. The API Level refers to the Android operating system version. The target refers to the Google APIs and Google Play Services available for that image. ABI stands for Application Binary Interface. In simpler terms, ABI is the architecture of the processor.
The first tab in the system image window is labeled recommended. As the name implies, it displays a list of recommended system images. The ARM Images tab displays the system images with ARM-based processors and different types of targets. The Other Images tab displays a bigger list of x86 processors, ARM processors, and target combinations.
Android Studio doesn’t come with a default system image, so when you create your first emulator, you won’t have any system images downloaded. Identify which system images are downloaded and ready for use by looking for a download icon next to the release name and by the color of the release name. If the system image is not downloaded, it will have a download icon next to the release name, and the font color will be grey, or disabled. If the system image is downloaded and ready to use, there will be no download icon, and the font color will be black.
From the recommended tab, click the system image with the release name UpsideDownCake, API Level 34, ABI arm64-v8a, and Target Android 14 with Google Play. This is the basic Android 14 system image. The details screen on the right side will provide more information about the system image selected. Now, click on the download icon next to the UpsideDownCake release name. A download dialog box will appear as the system image is installed in your SDK path. Some system images are over 1GB, so that download might take a while. You only need to download a system image one time. Once you download the system image, you’ll be able to reuse it for any other emulator you need to create.
When the download is complete, click Finish. You’ll be brought back to the system image selection screen. This time, there won’t be a download icon next to the release name and the font color will be black. You’re ready to continue with creating the emulator. Click to highlight the row with the release name UpsideDownCake, and click Next. You’ll be taken to the verify configuration screen.
The final step in the emulator creation process is to verify the hardware and system image selected and give it a name. Leave the default name for now. The default name gives you a clear description of the type of emulator you created. It will be listed in the device manager window after the emulator is created. If the hardware and system image are incorrect, you can navigate to the previous screen and make the changes necessary. This screen also gives you the ability to make a few minor adjustments to the emulator.
The verify configuration screen allows you to change a few more settings of your emulator. Click the Show Advanced Settings button and scroll down to see all the modifications you can make.
Click Finish to complete the creation of your emulator. After the emulator creation process, you’ll be brought back to the Android Studio IDE, and your new device will be listed in the device manager window.
Now that your emulator is created, you are ready to run it. In the device manager window, find the emulator you just created with the name Pixel 7 API 34. Click the start icon to start the emulator.
The running devices window will open as the emulator starts to load. The emulator may take some time to load depending on your computer, and the emulator configuration being used. While the emulator loads, you’ll see a progress indicator at the bottom of the Android Studio IDE along with a label that reads “Starting AVD”. When the emulator is done loading, the running devices window will display the emulator. The running devices window is where you can interact with the emulator. Swipe up on the emulator to see all the apps installed. You can interact with the emulator just like any Android device.
Switch back to the device manager to see how to stop, and edit the emulator. Notice that the start icon has changed to a stop icon. To stop the emulator, click the stop icon. The emulator will save its state and stop. Stopping an emulator is like powering off a physical device. Now that it’s stopped, the emulator won’t be visible on the running devices screen.
Find the vertical kabob icon for the Pixel 7 emulator and click on it. The context menu will expand and display additional options for the emulator. A few commonly used options here are delete, cold boot, wipe data, edit, and duplicate.
To duplicate the emulator, click the vertical kabob menu of your Pixel 7 emulator, and click on duplicate. Give it the name of Duplicate Emulator and click Finish. You’ll see the duplicate emulator appear as a separate device in the device manager.
Now you’ll see how to edit an existing emulator. Click the vertical kabob icon of the duplicate emulator and then click edit. The verify configuration screen will display. Click the Show Advanced Settings button and scroll to the emulated performance section. Change the boot option to cold boot. This will force the emulator to clear its state and always start from a clean power-up when you run it. Click Finish to save the changes.
In some cases when you use your emulator so often that it contains data you no longer need, or your app is in a hung state, you need to wipe all the data from it. To wipe the data from your emulator, find the duplicate emulator and once again open the context menu by clicking the vertical kabob icon. Click wipe data, and a dialog box will appear asking you to confirm the data wipe. Click Yes, and your emulator will be wiped of any unnecessary data.
If you no longer need an emulator or created one in error, you can always delete it. Open the context menu of the duplicate emulator one last time and click delete. A dialog box will appear asking you to confirm the deletion. Click Yes, and your emulator will be deleted.
By default, your emulator is set to quick boot mode which saves the state of the emulator and makes the next startup faster. The drawback is that the state is saved every time and you don’t always start from a clean initialization. On a physical device, you’d typically power off the phone and power it back on. The same can be done to the emulator by triggering a cold start. Open the context menu of your Pixel 7 emulator and click on cold boot. That will clear the state of the emulator and start it as if it were powered off and back on.
That ends this demo about emulators. Continue with the lesson to see how to use a physical device with Android Studio.