1. Before you begin
In this codelab, you'll take the Greeting Card app you built in the Create your first Android app codelab , set up an Android Virtual Device (AVD), and see your code in action on an Android Emulator.
Prerequisites
- Knowledge of how to set up, configure, and use apps, such as a word processor or a spreadsheet.
What you'll learn
- How to create an AVD and run an app on the Android Emulator
What you'll build
- A basic Android app from a template
What you'll need
- A computer with Android Studio installed
2. Watch the code-along video (Optional)
If you'd like to watch one of the course instructors complete the codelab, play the below video.
It's recommended to expand the video to full screen. In the video player, click the Full screen icon so you can see Android Studio and the code more clearly.
This step is optional. You can also skip the video and start the codelab instructions right away.
3. Run your app on the Android Emulator
In this task, you'll use the Device Manager to create an Android Virtual Device (AVD). An AVD is a software version, also called an emulator, of a mobile device that runs on your computer and mimics the configuration of a particular type of Android device. This could be any phone, tablet, TV, watch, or Android Auto device. You'll use an AVD to run the Greeting Card app.
Create an AVD
To run an Android app in an emulator on your computer, you first create a virtual device.
- In Android Studio, select Tools > Device Manager.
The Device Manager dialog opens. If you created a virtual device previously, it's listed in this dialog.
- Click + (Create Virtual Device).
The Virtual Device Configuration dialog appears.
The dialog shows a list of pre-configured devices, organized by category, from which you can choose. For each device, the table provides a column for its display size (in inches), screen resolution (in pixels), and pixel density (number of pixels per inch).
- Select Phone as the category.
- Select a phone, such as the Pixel 6, and then click Next.
This step opens another screen where you can choose the version of Android to run on your virtual device. This lets you test your app on different versions of Android.
- If there's a download link next to UpsideDownCake, click Download > Accept > Next > Finish. The presence of the download link indicates that the image isn't installed on your computer, in which case you must install the image before you can configure the virtual device. Expect the download to take some time to complete.
- In the Recommended tab, choose UpsideDownCake as the version of Android to run on the virtual device, and then click Next.
Android 14 UpsideDownCake is the latest version of Android at the time of writing, but you can choose any later stable version. For a list of stable versions, see Platform codenames, versions, API levels, and NDK releases.
This action opens another screen, where you can choose additional configuration details for your device.
- In the AVD Name field, enter a name for your AVD or use the default. Leave the rest of the fields unchanged.
- Click Finish.
This action returns to the Device Manager pane.
- Close the Device Manager dialog.
Run your app on the Android Emulator
- Select the virtual device that you created from the dropdown menu at the top of the Android Studio window.
- Click .
The virtual device starts just like a physical device. Expect this to take a while—potentially several minutes—for the emulator to start for the first time. The virtual device should open beside the code editor.
When your app is ready, it opens on the virtual device.
Great job! Your virtual device is now up and running. The app launches, and you can see the background color and greeting text on the screen.
4. Conclusion
Congratulations! You ran your app on the Android Emulator!
Summary
- To create an AVD, open your project, click Tools > Device Manager, and use the Device Manager to select a hardware device and system image.
- To run your app on a virtual device, ensure that you created a device, select the device from the toolbar menu, and click .