Updated about 7 hours ago | GitHub

Running Apps on Your Device

Overview

When building an Android app, it’s important that you always test your application on a real device in addition to emulators. This page describes how to set up your development environment and Android-powered device for testing and debugging on the device.

If you want an ideal SIM-unlocked phone to test on, then you might consider a Pixel phone.

Connect your Phone to Computer

Plug in your device to your computer with a USB cable. If you’re developing on Windows, you might need to install the OEM USB driver for your device; a third-party universal ADB USB driver also exists as a fallback.

Enable USB Debugging

The next step is to enable USB debugging so your phone can interact with your computer in a developer mode.

The following steps are needed:

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

Watch this video tutorial for a visual guide to getting USB debugging enabled.

Running your App

Now, we can launch apps from Android Studio onto our device:

  1. In the toolbar, select your app from the run configurations menu.
  2. In the target device menu, select the device that you want to run your app on.
  3. Click “Run” in the toolbar.

Once Gradle finishes building, Android Studio should install the app on your connected device and start it.

Troubleshooting

Not seeing your device in the target device menu? Try the following:

  • Unplug your device from the USB port on the computer
  • Restart the device by powering off and back on
  • Verify that Settings => Developer options => USB Debugging is enabled
  • Quit and re-launch Android Studio
  • Stop the ADB server with adb kill-server from a terminal, then run adb devices to restart it
  • Plug your device back into the USB port on the computer
  • Unlock the device and press “OK” on any dialog displayed

Now the phone should work as a debugging device as expected!

Still Not Working?

If after plugging the device into the computer and you don’t see any message about authorizing the device, then you may need to purchase another USB cable. Not all USB cables are enabled for data transfer. If there’s a chance that your cable may be a charging only cable, you can purchase a USB-C cable for Pixel or the micro-USB cable for Nexus 6 and prior.

References