How To Run Your Apps in Android Studio?

Anushka Choudhary
ILLUMINATION
Published in
5 min readMay 5, 2021
Photo by Christina Morillo from Pexels

Writing a code is simple. But running a code is what gives life to what you have written.

When I first started out with Android Studio, I was taking a lot of references while building my app. But the thing that kept me excited was the idea of running my app for the first time. However, I had to read some tutorials before getting started, so I thought why not create one on my own.

Android Studio provides two methods to run your apps. You can either run your app on a real device or create an Android Virtual Device (AVD) that the emulator can use to run your app.

In this blog, I will talk about running the app in both ways and some of the issues I encountered during this process.

Creating an AVD for Emulator

The simplest way to run your app is on an emulator. The emulator allows users to run their apps on different Android APIs without needing each physical device. It provides a default API but you can add the device modal and version of your own choice as well.

To run your app on the emulator all you need to do is select the device name from the drop-down list and click the run button.

Photo by Author

Adding a New AVD

To add a new AVD device follow these steps:
1. Click on the Available Device option and select AVD manager.
2. In the Android Virtual Device Manager window and click on Create Virtual Device.
3. Select the category and device name and press next. Select the Android version and click on download.
4. Click Next and wait for the download. Then click Finish.

Photo by Author

Problem: The Emulator Screen Goes Black

It happened to me a lot during the first few days of using the emulator. When I would run the program it would open to a black screen emulator. I tried everything including restarting the app, refreshing, changing the Internet connection, etc. But it was all in vain.

However, a very simple solution to this problem is to open the AVD manager and click on the rightmost arrow button next to your device name. Click on the option Cold Boot Now and your problem will be solved! Cold Boot refers to starting a device that has been turned off.

Photo by Author

Problem: Emulator Fills Up Only Part of the Screen

I am not sure if it is common problem or not. But I was one of those people facing this problem. And when I looked it up online, there were many others facing the same issue. Hence I wanted to cover this topic as well.

To fix this scaling issue you need to make Windows override the scaling settings. For that find the .exe file of your emulator. For me the path was: “C:\Users[Username]\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe”

Click on the Compatibility tab then select the Change High DPI settings. Check the Override high DPI scaling behavior check box and select the System option under Scaling performed by menu. Press OK to apply the changed settings.

Photo by Stackoverflow

Running App on A Physical Device

The best experience of an app can come from running it on your own device. This can be useful to check the network requirements, connectivity and sending out messages and notifications. The emulator can sometimes provide a false impression even if the testing is 100% perfect.

To run your app on your mobile you first need to enter the Developer mode and enable USB debugging.
1. Go to Settings-> About Phone. Then find the Build Number and tap it 6–7 times. A message pops us “You are now a developer”.
2. Go back to Settings and find USB Debugging and enable the developer option.
3. Connect your mobile phone to the laptop using a USB cable. If there are no USB drivers on your PC you can download it.
4. A dialog box appears on your mobile. Check the “Always allow this computer” option and click Allow.
5. Under the run option in your Android Studio, you will be able to see your device name. Select that and click run.

Photo by CodePath

Once done, the app will get downloaded on your mobile phone and you can run and test it out easily.

These are two simple ways to run your apps- on the emulator and mobile phone. It is very important to run the apps for debugging, checking connectivity and testing its functionality. So, I hope that this was a useful guide for the same. I will link some YouTube videos that I found helpful in these topics.

References:

  1. How to Run Android Studio App on Phone- Coding Pursuits
  2. How to Create Virtual Device (AVD) Emulator Android Studio and Run App- Vlad Voytenko

Read my previous blog:

--

--

Anushka Choudhary
ILLUMINATION

CSE undergrad student from India. Passionate in content writing, graphic design, UI design, web and app development.