Optional: Run your app on a mobile device

1. Before you begin

Prerequisites

  • Basic understanding of how to use Android Studio.
  • Ability to open and adjust settings on your Android device.

What you'll learn

  • How to enable your Android device to run apps from Android Studio.
  • How to connect and run an app in Android Studio on a physical Android device.

What you need

  • Android Studio downloaded and installed on your computer.
  • An app project set up in Android Studio.
  • An Android device, such as a phone or tablet.
  • A USB cable to connect your Android device to your computer via their USB ports.

2. Turn on USB debugging

To let Android Studio communicate with your Android device, you must enable USB debugging in the Developer options settings of the device.

To show developer options and enable USB debugging:

  1. On your Android device, open Settings, and search for About phone.
  2. Tap on About phone, and then tap Build number seven times. Enter your device password or pin, if prompted.
  3. Return to Settings, and tap System. Developer options should now appear in the list. You may need to open the Advanced options to find it.
  4. Tap Developer options, and then turn on USB debugging.

3. Install the Google USB Driver (Windows only)

If you've installed Android Studio on a Windows-based computer, you must install a USB device driver before you can run your app on a physical device.

  1. In Android Studio, click Tools > SDK Manager.

The Settings for New Projects window displays.

88b26c36433a1575.png

  1. Click the SDK Tools tab.
  2. Select Google USB Driver and click OK.

When done, the driver files are downloaded into the android_sdk/extras/google/usb_driver directory. You should now be able to connect and run your app from Android Studio.

4. Run your app on the Android device (all operating systems)

Now you can connect your device and run the app from Android Studio.

  1. Connect the Android device to your development machine with a USB cable. A dialog should appear on the device, asking to allow USB debugging.

3ef4665b08f898b2.png

  1. Select the Always allow option to remember this computer. Tap OK.
  2. In Android Studio on your computer, make sure your device is selected in the dropdown. Click This is the Android Studio Run icon.

7f0d549b45053f41.png

  1. Select your device and then click OK.

Android Studio installs the app on your device and runs it.

5. Troubleshooting

  • If your computer runs Linux or Windows, and you can't run your app on a physical Android device, see Run apps on a hardware device for additional steps.
  • If your computer runs Windows and the emulator installation doesn't work, see Install OEM USB Drivers for the appropriate USB driver for your device.
  • If Android Studio doesn't recognize your device, unplug the USB cable and plug it back in. Restart Android Studio.
  • If your computer still doesn't find the device or declares it unauthorized, disconnect the USB cable. Then on the device, tap Settings > Developer options > Revoke USB debugging authorizations. Reconnect the device to your computer. When prompted, grant authorizations.

6. Conclusion

You learned how to run an app in Android Studio on your physical Android device!

7. Learn more