Paramclasses Academy - Blog

Tutorials Details

←
Post 33 of 40
→

How to Run Android Apps on an Emulator and a Real Android Phone ?

How to Run Android Apps on an Emulator and a Real Android Phone ?

November 4, 2026

Introduction

After developing an Android application in Android Studio, the next important step is to run and test it.

Android Studio provides two main ways to run an application:

  1. Android Emulator: A virtual Android device that runs on your computer.

  2. Real Android Phone: A physical Android device connected to your computer using USB or Wi-Fi debugging.

Both methods allow developers to install, launch, test, and debug Android applications.

In this tutorial, we will learn how to configure an Android Emulator, create a virtual device, connect a real Android phone, and run the same Java application on both devices.

By the end of this tutorial, you will learn how to:

  • Understand Android Emulator and AVD.

  • Create a virtual Android device.

  • Download and install an Android system image.

  • Run an application on an emulator.

  • Enable Developer Options on a real Android phone.

  • Enable USB Debugging.

  • Connect a phone to Android Studio.

  • Run an application using a USB cable.

  • Connect a phone using Wireless Debugging.

  • Troubleshoot common device connection problems.

1. What Is an Android Emulator?

An Android Emulator is a virtual Android device that allows developers to run and test applications on a computer.

It simulates the behavior of an Android phone without requiring a physical device.

Using an emulator, developers can test applications on different:

  • Android versions.

  • Screen sizes.

  • Screen resolutions.

  • Device configurations.

  • Hardware profiles.

For example, you can create virtual devices that simulate Pixel phones with different Android versions.

Benefits of Android Emulator

  • No physical Android phone is required.

  • Test applications on multiple Android versions.

  • Simulate different screen sizes.

  • Test application layouts.

  • Simulate device rotation and location.

  • Debug applications directly from Android Studio.

2. What Is an Android Virtual Device (AVD)?

AVD stands for Android Virtual Device.

An AVD is a configuration that defines the characteristics of a virtual Android device.

It includes information such as:

  • Device model.

  • Android version.

  • API level.

  • Screen resolution.

  • RAM configuration.

  • Storage configuration.

  • System image architecture.

For example, you can create a Pixel virtual device running Android 15.

Android Studio uses this configuration to start the Android Emulator.

3. Difference Between Emulator and Real Android Device

An emulator is a software-based virtual device, while a real Android device is a physical smartphone or tablet.

Android Emulator:

  • Runs on your computer.

  • Supports multiple virtual device configurations.

  • Useful for testing different Android versions.

  • Can simulate location, rotation, and other device conditions.

Real Android Device:

  • Runs on actual smartphone hardware.

  • Helps test real-world performance.

  • Provides access to physical hardware features.

  • Helps identify device-specific issues.

Both are important for Android application testing.

4. Check Android Studio Setup

Before running an application, make sure Android Studio is installed correctly.

Open Android Studio and check that:

  1. Your Android project opens successfully.

  2. Gradle Sync completes without errors.

  3. Android SDK is installed.

  4. Android SDK Platform Tools are available.

  5. Android Emulator is installed if you want to use a virtual device.

To check SDK components:

  1. Open Android Studio.

  2. Go to Tools → SDK Manager.

  3. Open the SDK Platforms tab.

  4. Check that the required Android SDK platform is installed.

  5. Open the SDK Tools tab.

  6. Check Android SDK Platform-Tools and Android Emulator.

  7. Click Apply if any required component needs installation.

Your project's compile SDK and installed SDK components should be compatible.

5. Create an Android Virtual Device

Now we will create our first virtual Android device.

Follow these steps:

  1. Open your Android Studio project.

  2. Go to Tools → Device Manager.

  3. Open the Device Manager panel.

  4. Click Add Device or the plus icon.

  5. Select Create Virtual Device if shown.

  6. Choose a phone hardware profile, such as Pixel.

  7. Click Next.

Now select an Android system image.

For example, you can choose an available stable Android release such as Android 15 or another supported version.

If the system image is not installed:

  1. Click the Download option.

  2. Accept the required license agreement.

  3. Wait for the download to complete.

  4. Click Finish.

Finally:

  1. Review the AVD configuration.

  2. Enter a suitable device name.

  3. Click Finish.

Your virtual Android device is now created.

6. Start the Android Emulator

After creating the AVD, you need to start it.

Follow these steps:

  1. Open Tools → Device Manager.

  2. Find your newly created virtual device.

  3. Click the Play icon next to the device.

  4. Wait for the emulator to start.

  5. The virtual Android phone appears on your computer screen.

The first launch may take some time because Android needs to initialize the virtual device.

After startup, you can use the emulator like a normal Android phone.

You can:

  • Open applications.

  • Navigate between screens.

  • Rotate the device.

  • Change volume.

  • Simulate location.

  • Test application behavior.

7. Create a Simple Android Application for Testing

Now we will create a simple Java application and run it on the emulator.

Open Android Studio.

Follow these steps:

  1. Click New Project.

  2. Select Empty Views Activity.

  3. Enter the project name: DeviceTestingApp.

  4. Select Java as the programming language.

  5. Select a suitable minimum SDK.

  6. Click Finish.

Wait for Gradle Sync to complete.

We will create a simple application that displays a welcome message and a button.

8. Design the Application Layout

Open activity_main.xml.

Replace its content with:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:padding="20dp">

    <TextView
        android:id="@+id/txtWelcome"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Welcome to Android Development!"
        android:textSize="22sp"
        android:textStyle="bold"
        android:gravity="center"
        android:padding="16dp" />

    <Button
        android:id="@+id/btnTest"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Test Application" />

</LinearLayout>

Understanding the XML Components

LinearLayout: Arranges the components vertically.

TextView: Displays the welcome message.

Button: Allows the user to test the application.

9. Add Java Code

Open MainActivity.java.

Add the following code:

package com.example.devicetestingapp;

import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private Button btnTest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        btnTest = findViewById(R.id.btnTest);

        btnTest.setOnClickListener(v -> {

            Toast.makeText(
                    MainActivity.this,
                    "Application is running successfully!",
                    Toast.LENGTH_SHORT
            ).show();

        });
    }
}

Important: Replace the package declaration with the actual package name of your project.

Understanding the Java Code

onCreate(): This method is called when the Activity is created.

setContentView(): Loads the XML layout.

findViewById(): Finds the button using its XML ID.

setOnClickListener(): Handles the button click event.

Toast.makeText(): Displays a short message on the screen.

This application will help us verify that the app runs correctly on both virtual and physical devices.

10. Run the Application on Android Emulator

Now we will install and run the application on the emulator.

Follow these steps:

  1. Open your project in Android Studio.

  2. Start the Android Emulator.

  3. Wait until the virtual device finishes booting.

  4. Open the device selector in the Android Studio toolbar.

  5. Select your running virtual device.

  6. Click the Run button.

  7. Android Studio builds the application.

  8. The application is installed on the emulator.

  9. MainActivity opens automatically.

Now click the Test Application button.

You should see the message:

Application is running successfully!

This confirms that your application is running on the Android Emulator.

11. What Is USB Debugging?

USB Debugging is an Android Developer Option that allows a computer to communicate with an Android device through Android Debug Bridge (ADB).

ADB is a command-line tool that allows developers to:

  • Install applications.

  • Debug applications.

  • View device information.

  • Execute shell commands.

  • Transfer files.

  • Communicate with connected Android devices.

Android Studio uses ADB to install and debug applications on a connected phone.

12. Enable Developer Options on a Real Android Phone

Before connecting your phone to Android Studio, you need to enable Developer Options.

The exact steps may vary depending on the phone manufacturer.

For many Android phones:

  1. Open the phone's Settings.

  2. Go to About Phone.

  3. Find Build Number.

  4. Tap Build Number seven times.

  5. Enter your phone PIN or password if requested.

  6. You should see a message confirming that Developer Options are enabled.

On some devices, Build Number may be located under:

Settings → About Phone → Software Information → Build Number

After enabling Developer Options, return to the Settings menu.

13. Enable USB Debugging

Now enable USB Debugging.

Follow these steps:

  1. Open your phone's Settings.

  2. Open Developer Options.

  3. Find USB Debugging.

  4. Turn on the USB Debugging switch.

  5. Confirm the warning dialog if it appears.

USB Debugging is now enabled.

Keep in mind that the location of Developer Options and USB Debugging can vary across Android devices.

14. Connect Your Android Phone Using a USB Cable

Now connect your phone to your computer.

Follow these steps:

  1. Take a USB data cable.

  2. Connect your Android phone to the computer.

  3. Unlock your phone.

  4. Select File Transfer or another suitable USB mode if your device requires it.

  5. Watch for the USB Debugging authorization dialog.

  6. Select Allow to authorize your computer.

If the authorization dialog does not appear, check the USB cable, connection mode, and debugging settings.

Check Device Connection in Android Studio

Open Android Studio.

Look at the device selector in the toolbar.

Your connected phone should appear in the available device list.

Select your phone as the deployment target.

If your phone appears in the list, Android Studio can use it to run the application.

15. Run the Application on a Real Android Phone

Now follow these steps:

  1. Open your Android project.

  2. Connect your phone using USB.

  3. Enable USB Debugging.

  4. Authorize the computer.

  5. Wait for Android Studio to detect the phone.

  6. Select your physical phone from the device selector.

  7. Click Run.

  8. Android Studio builds the application.

  9. The application is installed on your phone.

  10. MainActivity opens automatically.

Now tap the Test Application button.

You should see:

Application is running successfully!

Your Android application is now running on a real smartphone.

16. Connect an Android Phone Using Wireless Debugging

Android 11 and later support wireless debugging through ADB.

This allows developers to connect a phone to Android Studio without keeping a USB cable connected.

For wireless debugging, your phone and computer must be connected to the same Wi-Fi network.

Follow these steps:

  1. Enable Developer Options on your phone.

  2. Open Developer Options.

  3. Enable Wireless Debugging.

  4. Confirm the authorization prompt if shown.

  5. Open Android Studio.

  6. Select Pair Devices Using Wi-Fi from the device or run configuration menu.

  7. Choose QR code pairing or pairing-code pairing.

  8. Follow the instructions shown on your phone and computer.

  9. Complete the pairing process.

  10. Select the connected phone in Android Studio.

Your phone should now appear as a wireless debugging target.

You can click Run to install and launch your application.

Important: Wireless debugging requires a compatible Android version and updated Android SDK Platform Tools. Keep your phone and computer on the same trusted network.

17. Verify Device Connection Using ADB

You can also verify the connected device using the ADB command-line tool.

Open the Terminal in Android Studio.

Run:

adb devices

If your device is connected and authorized, you may see output similar to:

List of devices attached
R58M123456A    device

The device identifier will be different for each phone.

Understand the Output

device: The device is connected and authorized.

unauthorized: The phone has not yet authorized the computer for debugging.

offline: ADB can detect the device, but the connection is not currently ready.

If the device does not appear, check the USB cable, USB debugging, drivers, and ADB connection.

18. Emulator vs Real Phone: Which One Should You Use?

Both testing methods are important.

Use the Android Emulator when you need to:

  • Test different screen sizes.

  • Test different Android versions.

  • Simulate location and device rotation.

  • Quickly test application layouts.

  • Run multiple virtual device configurations.

Use a real Android phone when you need to:

  • Test real hardware behavior.

  • Check actual device performance.

  • Test camera and sensor features.

  • Verify real-world touch interactions.

  • Test manufacturer-specific behavior.

For professional Android development, test your application on both an emulator and at least one real device before releasing it.

19. Common Errors and Their Solutions

Error 1: Android Emulator Is Not Starting

Possible reasons:

  • Insufficient system resources.

  • Missing emulator components.

  • Hardware virtualization is unavailable or disabled.

  • Graphics compatibility problems.

Solution:

  • Check Android Emulator installation in SDK Manager.

  • Check your computer's virtualization configuration.

  • Close unnecessary applications.

  • Update emulator and graphics drivers.

  • Try a compatible system image.

Error 2: Android Phone Is Not Detected

Possible reasons:

  • USB Debugging is disabled.

  • The USB cable supports charging only.

  • Required Windows USB drivers are missing.

  • The phone has not authorized the computer.

Solution:

  • Enable USB Debugging.

  • Try another USB data cable.

  • Check the USB connection mode.

  • Accept the RSA authorization dialog.

  • Install the appropriate OEM USB driver on Windows if required.

Error 3: Device Shows Unauthorized

Possible reason: The phone has not approved the computer's debugging request.

Solution:

  1. Unlock your phone.

  2. Look for the USB Debugging authorization dialog.

  3. Select Allow.

  4. Run adb devices again.

Error 4: Application Is Not Installing

Possible reasons:

  • Gradle build failed.

  • Device storage is insufficient.

  • Application installation failed.

  • ADB connection is unstable.

Solution:

  • Check the Build output.

  • Resolve compilation errors.

  • Check available device storage.

  • Reconnect the device.

  • Try running the application again.

Error 5: Emulator Is Running Slowly

Possible reasons:

  • Limited RAM.

  • High CPU usage.

  • Missing hardware acceleration.

  • Incompatible graphics configuration.

Solution:

  • Close unnecessary applications.

  • Use an appropriate virtual device configuration.

  • Check hardware acceleration.

  • Reduce the emulator's resource requirements if necessary.

20. Best Practices for Android Application Testing

Follow these practices when testing Android applications:

  • Test on multiple Android versions.

  • Test on different screen sizes.

  • Test on both emulator and physical devices.

  • Check application behavior after screen rotation.

  • Test permission requests.

  • Check network-dependent features.

  • Use Logcat to identify errors.

  • Keep Android SDK and Platform Tools updated.

  • Test on real hardware before publishing.

  • Disable USB or wireless debugging when it is no longer needed on personal devices.

Conclusion

In this tutorial, we learned how to run Android applications using Android Studio.

We covered Android Emulator, Android Virtual Devices, system images, Developer Options, USB Debugging, ADB, and Wireless Debugging.

We also created a simple Java application and successfully learned the steps required to deploy it to both a virtual Android device and a real smartphone.

Testing applications on different devices is an essential part of Android development. It helps developers identify compatibility problems, UI issues, performance problems, and device-specific errors before releasing an application.

Frequently Asked Questions

1. What is an Android Emulator?

An Android Emulator is a virtual Android device that allows developers to run and test applications on a computer.

2. What is an AVD in Android Studio?

AVD stands for Android Virtual Device. It defines the hardware and software configuration of a virtual Android device.

3. What is USB Debugging?

USB Debugging allows Android Studio and other development tools to communicate with an Android device through ADB.

4. Can we run Android applications without an emulator?

Yes. You can connect a real Android phone to Android Studio using USB Debugging or Wireless Debugging.

5. What is ADB?

ADB stands for Android Debug Bridge. It is a command-line tool used to communicate with Android devices and emulators.

6. Can we run Android apps wirelessly?

Yes. Android 11 and later support Wireless Debugging, allowing developers to deploy and debug applications over Wi-Fi.

7. Should we test Android applications on real devices?

Yes. Real-device testing helps verify actual hardware behavior, performance, compatibility, and user experience.

8. Is an Android Emulator the same as a real phone?

No. An emulator is a virtual device running on a computer, while a real phone uses physical Android hardware.

←
Post 33 of 40
→