Skip to Content

Running Your App on a Device

Learn how to test your apps on real or emulated Android devices

To run an Android application we need a device—either a hardware device or a virtual device. Virtual devices are powered by the Android emulator, which ships with the developer tools.

The Android Emulator simulates Android devices on the computer so that we can test our application on a variety of devices and Android API levels without needing to have each physical device.

The emulator has almost all of the capabilities of a real Android device. We can simulate user gestures, incoming phone calls and text messages, specify the GPS location of the device, simulate different network speeds, simulate rotation and other hardware sensors, access the Google Play Store, and more.

Navigating the Emulator Screen

Swipe the screen: Point to the screen, press and hold the primary mouse button, swipe across the screen, and then release.

Drag an item: Point to an item on the screen, press and hold the primary mouse button, move the item, and then release.

Tap (touch): Point to the screen, press the primary mouse button, then release. For example, you could click a text field to start typing in it, select an app, or press a button.

Double-tap: Point to the screen, press the primary mouse button quickly twice, and then release.

Touch and hold: Point to an item on the screen, press the primary mouse button, hold, and then release. For example, you could open options for an item.

Type: You can type in the emulator by using your computer keyboard, or using a keyboard that pops up on the emulator screen. For example, you could type in a text field after you selected it.

Pinch and spread: Pressing Control (Command on Mac) brings up a pinch gesture multi-touch interface. The mouse acts as the first finger, and across the anchor point is the second finger. Drag the cursor to move the first point. Clicking the left mouse button acts like touching down both points, and releasing acts like picking both up.

Vertical swipe: Open a vertical menu on the screen and use the scroll wheel (mouse wheel) to scroll through the menu items until you see the one you want. Click the menu item to select it.

Run Apps on a Hardware Device

Android Studio also makes it convenient to test our apps on real physical devices. Running an Android app for testing on a real device is faster than running an emulator. We will look at how to set up our development environment and Android device for testing and debugging over an Android Debug Bridge (ADB) connection.

Steps to Enable USB Debugging

  1. Plug-in your Android Device to Computer via USB
  2. Open the “Settings” App on the Device
  3. Scroll down to the bottom to find “About phone” item
  4. Scroll down to the bottom to find “Build number” section
  5. Tap on “Build Number” 7 times in quick succession
  6. You should see the message “You are now a developer!”
  7. Go back to main “Settings” page
  8. Scroll down the bottom to find “Developer options” item
  9. Turn on “USB Debugging” switch and hit “OK”
  10. Unplug and re-plug the device
  11. The dialog appears “Allow USB Debugging?”
  12. Check “Always allow from this computer” then hit “OK”

Running Your App:

  1. Select one of your projects and click “Run” from the toolbar.
  2. In the “Choose Device” window that appears, select the “Choose a running device” radio button, select the device, and click OK.
  3. Once Gradle finishes building, Android Studio should install the app on your connected device and start it.

Ready to Learn More?

Find the course that's right for you! Explore our catalog or get a recommendation.