Home and Learn: Android Course


Run your Android Apps

To run an app in Android Studio, you can click the green arrow in the menu bars at the top:

Or you can click the Run menu, then select Run (we've cropped a few items from the menu below):

Running your apps from the Run menu

If you already have a virtual device set up in Android Studio, then your app will launch and you'll see an image of a phone appear on the right:

Virtual Device running in Android Studio.

We'll explore this soon. But, f you haven't set up a virtual device, you may see a screen appear asking you to choose one:

The Select Deployment Target  dialogue box

As you can see, we don't have a real device plugged in to this computer, as it says none under Connected Devices. (We'll plug a real device in, soon.) There is an option under Available Virtual Devices, however. For us, this is Nexus 5X API 25 x86.

If you don't see the above dialog box, then you can select a device from the dropdown list to the left of the Run button:

Available Device dropdown in Android Studio

You can also set up a virtual device by selecting Device Manager from the menu above. If you do, you'll see this screen appear on the right of Android Studio:

The Device Manager in Android Studio.

There are two tabs at the top, Virtual and Physical. If you don't have a phone plugged in to your computer, the Physical tab will be empty. The Virtual tab shows you what virtual devices you have already set up. To set up a new one, click the Create Device button at the top. you'll see this:

Virtual Device configuration screen in Android Studio.

In the image above, we've selected the Phone category. In the middle, we've selected tp set up a Pixel 6 virtual device. Click Next to see this screen:

This screen is where you can select a system image for when the device loads. As the message on the right says, the recommended images run faster and support Google APIs.

Click Next and you're almost there. This is the final screen you'll see:

The Verify Configuration screen in Android Studio.

Not much to do here but confirm you choices. Click Finish to finish setting up your new virtual device.

After you have finished setting up the new device, you should see it appear on your Device Manager list:

A new device added to the Device Manager list.

You'll also see it on the menu to the left of the Run button at the top of Android Studio:

Device list in Android Studio

When you click the Run button now, your app will start on your new virtual device. The idea here is that you can test your app on a wide range of devices to see what it looks like:

Pixel 6 running on a virtual device in Android Studio.

Now have a look at the control strip at the top of the the emulated phone. This one:

The control strip is where you can play around with your new virtual device. Try clicking on some of the controls above to see what they do.

 

 

Testing on a real device

We recommend testing on a real phone or tablet. The Android Virtual Device gives a good impression of what your app will look like, but it's not perfect. There's no substitute for plugging in a real device into your computer via a USB micro cable.

When you do plug a real device into your computer, click Run again to see the dialogue box appear: (Newer versions if Android Studio will have the real device already selected in the dropdown to the left of the Run button so may not see this dialog box.)

A real device connected to Android Studio

The connected device is an old Samsung Galaxy S6. Notice that it tells you the maximum API number that this phone supports, which is API 23. So if you're not sure which API number your device supports, plug it in to your computer and have a look at the Connected Devices entry. (Sadly, newer versions of Android Studio may not have this information.)

Select your phone or tablet from the Connected Devices section. Click OK on the dialogue box and you should see your app appear on your phone/tablet.

 

Stopping your apps

To stop your app running and return to Android Studio, you can click the stop icon at the top:

The Stop app icon in the Android Studio toolbar

You can also click the Run menu, then select Stop app:

The Stop app item on the menu

A shortcut is to hold down the CTRL key on your keyboard and then press the F2 key.

Now that you have some idea of how to create and run apps, we'll start to explore in more detail. First up is Layouts.

Back to the Android Contents Page

 


Email us: enquiry at homeandlearn.co.uk