1. Before you begin
In this codelab, you learn how to connect your app in Android Studio to your physical Android device. You can either connect your device with a cable or with Wi-Fi. This codelab will cover both cases. Note that Android Studio gets updated and sometimes the UI changes so it is okay if your Android Studio looks a little different than what is shown on the screen.
- Basic knowledge 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'll 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 running Lollipop or later.
- (Optional) A USB cable to connect your Android device to your computer through their USB ports.
2. Watch the code-along video (Optional)
If you'd like to watch one of the course instructors complete the codelab, play the below video.
It's recommended to expand the video to full screen (with this icon in the lower right corner of the video) so you can see Android Studio and the code more clearly.
This step is optional. You can also skip the video and start the codelab instructions right away.
3. Enable 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:
- On your Android device, tap Settings > About phone.
- Tap Build number seven times.
- If prompted, enter your device password or pin. You know you succeeded when you see a You are now a developer! message.
- Return to Settings and then tap System > Developer options.
- If you don't see Developer options, tap Advanced options.
- Tap Developer options and then tap the USB debugging toggle to turn it on.
If you installed Android Studio on Windows, you must install a USB device driver before you can run your app on a physical device.
- In Android Studio, click Tools > SDK Manager. The Preferences > Appearance & Behavior > System Settings > Android SDK dialog opens.
- Click the SDK Tools tab.
- Select Google USB Driver and then click OK.
When done, the driver files are downloaded into the
android_sdk\extras\google\usb_driver directory. Now you can connect and run your app from Android Studio.
4. Run your app on the Android device with a cable
There are two ways to connect your device to Android Studio, through a cable or through Wi-Fi. You can choose whichever you like more.
To run your app from Android Studio on your Android device:
- Connect your Android device to your computer with a USB cable. A dialog should appear on your device, which asks you to allow USB debugging.
- Select the Always allow from this computer checkbox and then tap OK.
- In Android Studio on your computer, make sure your device is selected in the dropdown. Click .
- Select your device and then click OK. Android Studio installs the app on your device and runs it.
- If your device runs an Android platform that isn't installed in Android Studio and you see a message that asks whether you want to install the needed platform, click Install > Continue > Finish. Android Studio installs the app on your device and runs it.
5. Run your app on the Android device with Wi-Fi
If you don't have a cable, you can also connect and run your app on your device with Wi-Fi.
- Ensure that your computer and device are connected to the same wireless network.
- Ensure that your device runs Android 11 or higher. For more information, see Check & update your Android version.
- Ensure that your computer has the latest version of Android Studio. To download it, see Android Studio.
- Ensure that your computer has the latest version of the SDK Platform Tools.
Pair your device
- In Android Studio, select Pair Devices Using Wi-Fi from the run configurations drop-down menu.
The Pair devices over Wi-Fi dialog opens.
- Go to Developer options, scroll down to the Debugging section and turn on Wireless debugging.
- On the Allow wireless debugging on this network? popup, select Allow.
- If you want to pair your device with a QR code, select Pair device with QR code and then scan the QR code on your computer. Alternatively, if you want to pair your device with a pairing code, select Pair device with pairing code and then enter the 6-digit code.
- Click run and you can deploy your app to your device.
- 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: try unplugging the USB cable and plug it back in or restarting Android Studio.
- If your computer still doesn't find the device or declares it unauthorized: disconnect the USB cable. On the device, tap Settings > Developer options > Revoke USB debugging authorizations. Reconnect the device to your computer. When prompted, grant authorizations.
You learned how to run an app in Android Studio on your physical Android device!
- You can run Android apps on your physical device through a cord or through Wi-Fi.
- Windows users need to install a USB debugging driver to run apps on their physical device.
- If you are running your app through Wi-Fi, you can pair using a QR code or a 6 digit code.