Most visited

Recently visited

Running Your App

In the previous lesson, you created an Android project. The project contains a default app that displays "Hello World". In this lesson, you will run the app on a device or emulator.

Run on a Real Device

Set up your device as follows:

  1. Connect your device to your development machine with a USB cable. If you're developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the OEM USB Drivers document.
  2. Enable USB debugging on your device by going to Settings > Developer options.

    Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

Run the app from Android Studio as follows:

  1. In Android Studio, select your project and click Run from the toolbar.
  2. In the Select Deployment Target window, select your device, and click OK.

Android Studio installs the app on your connected device and starts it.

Run on the Emulator

Before you run your app on an emulator, you need to create an Android Virtual Device (AVD) definition. An AVD definition defines the characteristics of an Android phone, tablet, Android Wear, or Android TV device that you want to simulate in the Android Emulator.

Create an AVD Definition as follows:

  1. Launch the Android Virtual Device Manager by selecting Tools > Android > AVD Manager, or by clicking the AVD Manager icon in the toolbar.
  2. On the AVD Manager main screen, click Create Virtual Device.
  3. In the Select Hardware page, select a phone device, such as Nexus 6, then click Next.
  4. In the Select Image page, choose the desired system image for the AVD and click Next.
  5. Verify the configuration settings (for your first AVD, leave all the settings as they are), and then click Finish.

For more information about using AVDs, see Create and Manage Virtual Devices.

Run the app from Android Studio as follows:

  1. In Android Studio, select your project and click Run from the toolbar.
  2. In the Select Deployment Target window, select your emulator and click OK.

It can take a few minutes for the emulator to start. You may have to unlock the screen. When you do, My First App appears on the emulator screen.

That's how you build and run your Android app on the emulator! To start developing, continue to the next lesson.

Hooray!