Coders' Guidebook

How to run an android app on a virtual device emulator

In this tutorial, we will explore how to set up a virtual device using Android Studio so you can test your app on your computer.

Setting up a virtual device

To set up a virtual device, press Tools > AVD Manager (AVD is short for Android Virtual Device).


Next, press 'Create Virtual Device...'.


You will see a list of possible virtual devices. Each device has a different screen size, resolution and pixel density. There is also a 'New Hardware Profile' button which allows you to customise the technical specifications of the device, but we will ignore that for now. Simply select the device you want to use then press Next. For this example, we will choose Pixel 3.


You will be prompted to select an API release. Most often you will want to select an API equal to or greater than the minimum API for new apps submitted to the Google Play store. At the time of writing, the minimum accepted API is API 29.


In the following screen, you will get the chance to verify the configuration. The default values are fine for our purposes so simply press Finish. The newly configured virtual device will now be listed in the Android Virtual Device Manager!


You can now close the Android Virtual Device Manager window. In the action bar above the editor window, you will notice the virtual device is listed as one of the available devices. This means the virtual device is ready to be used.


Running your app on the virtual device

To run an app, simply press the green play button next to where the virtual device is listed.


Android Studio will then compile and load the app on the virtual device. In this example, the polaroid images app from a previous tutorial is being run. You can even interact with the app using your mouse and keyboard!


When the app is running, you may notice some new buttons in the toolbar. The three buttons highlighted below are useful when you need to restart the app after making some changes to the underlying code. Using them means you won't have to close and reopen the virtual device itself. There is also a red square 'stop' button. Pressing this button closes the app but not the virtual device. This is useful if you want to stop the app running in the background but not close the virtual device entirely.


And there we have it! You can now run your app without the need for an actual phone or tablet. It is good practice to run your app regularly and check everything is working as you intended. We will look further at how to test our app (including what to do if it crashes) in future tutorials.

<<< Previous

Next >>>