Using USB connection
Before you can start debugging on your device, decide if you want to connect the device using a USB cable or Wi-Fi. Then do the following:
On the device, open the Settings app, select Developer Options, and then enable USB debugging (if applicable).
Note: If you do not see Developer options, follow the instructions to enable developer options.
Option 1: Connect using USB
When you are set up and plugged in over USB, you can click Run in Android Studio to build and run your app on the device.
You can also use adb to issue commands, as follows:
Verify that your device is connected by running the adb devices command from your android_sdk/platform-tools/ directory. If connected, you'll see the device listed.
Issue any adb command with the -d flag to target your device.
Option 2: Connect using Wifi
Android 11 (and later) supports deploying and debugging your app wirelessly from your workstation via Android Debug Bridge (adb). For example, you can deploy your debuggable app to multiple remote devices without physically connecting your device via USB and contending with common USB connection issues, such as driver installation.
To use wireless debugging, you need to pair your device to your workstation using a pairing code. Your workstation and device must be connected to the same wireless network. To connect to your device, follow these steps:
Enable the Wireless debugging option under Developer options.
On the dialog that asks Allow wireless debugging on this network?, click Allow.
Select Pair device with pairing code. Take note of the pairing code, IP address, and port number displayed on the device (see image).
On your workstation, open a terminal and navigate to android_sdk/platform-tools.
Run adb pair ipaddr:port. Use the IP address and port number from step 2.
When prompted, enter the pairing code that you received in step 3. A message should indicate that your device has been successfully paired.