Home   Courses   Blog   About

How to run an app in an Emulator for beginners

While building apps we want to run them frequently, to check the design or to test if everything is working perfectly. We will show you how to run an app in an emulator. We will start without a virtual device to show you, how you can create it.

We have already created our new app, if you want to know how we do it check our video and article about it as well. 

We are using an empty app to remove any possibilities of an error. We only have an empty activity ready for us, named MainActivity.

You can run the app in two ways:

  1. Using the menu Run and then the Run App option
  2. Using the Play icon from the toolbar
     

 

This is how the “Select Deployment Target” window will look like if you do not have any virtual devices ready to run yet. We need to create it first, click “Create New Virtual Device” button to add a new one.

In window “Select Hardware” you will choose a virtual device we will create.

We recommend that you choose a Nexus 5X or Nexus 5, since it is easier to place on you desktop due to the window size.

Choose it and click Next

Next you will see a recommended selection of an Android versions.

You can see the name and the API Level in the list. This choice is just like picking your new phone. Depending on the version you choose it will have different features available. You also have a button for recommended, x86 Images and Other Images. Most of the time you will want to choose x86 Images and we will too. So click that button.

In the list you will also see the column target (this is actual Android version, that will be on your emulator) and in brackets Google Play, Google APIs or without. We recommend using Google APIs

Even though Andorid P is already available we would recommend to choose an older version, to check if everything is working for users with older versions. But you can also add a new virtual device and check it on newer versions as well. You can have more than one virtual device.
So we will choose Marshmallow (you can see, that there is no “Download” link beside it, this means that the SDK (Software Development Kit) is already downloaded). If you have a Download button beside it, click it.

Choose it and click Next

The last window lets us choose details about our new virtual device.

That is it, we just need to finish and we will have a new virtual device available for us to use. We need to wait for Android Studio to finish.

Now we can choose a virtual device when running our app.

When we click OK, the emulator will load and it will have all the features of a normal Android device. The app will run automatically for us, but it can take some time. So check if Android Studio is still working, building an APK and installing it on your emulator. Status is shown on the bottom of the Android Studio screen.
 

Error if Virtualization is not turned ON

You might get an error because your Virtualization is not turned ON in your BIOS. To turn it ON just google “How to turn on virtualization in BIOS” + add your computer model or motherboard model (as your knowledge in coding grows so will your skills with google search :)).

 

You can also run on your device

If you are not ready to change the settings in your BIOS or you would like to see how this small program looks on your phone, click this link to see how you can connect your phone to Android Studio https://developer.android.com/studio/run/device