43

I am trying to connect my Android 11 device with the android studio over adb wifi but it is not working.

I updated to the latest stable bumblebee and updated my SDK I tried turning off the firewall on my pc but it is the same result.

When I use the QR code method my android phone just shows "pairing device" and nothing happens If I try the code method, the android studio just shows "searching for devices" but nothing happens

and, yes, I enabled wireless debugging on my phone and I am connected to the same wifi network.

I don't know if the problem is with my computer or phone. I do not have any other Android11+ phone to try with

Rahul
  • 3,293
  • 2
  • 31
  • 43
Faysal Ahmet
  • 743
  • 2
  • 4
  • 10

16 Answers16

88

I had this issue; it paired fine the first time in-app but never worked again when trying to pair or connect directly from Android Studio.

What I now do to connect/pair is the following:

  • Open your phone's settings and be sure to enable wireless debugging in developer options
  • Click Pair device with pairing code, and keep it on that screen.
  • Now, go into a terminal and cd into the %LOCALAPPDATA%\Android\sdk\platform-tools directory.
  • After that, type adb pair <PHONE_IP>:<PHONE_PORT>
  • Input the pairing code when prompted
  • Finally, run adb connect <PHONE_IP>:<PHONE_PORT_PROVIDED_ABOVE_PAIR_WITH_QR_BUTTON>, and it should connect; Android Studio will automatically detect the connection, so that's it!
Rahul
  • 3,293
  • 2
  • 31
  • 43
13-05
  • 993
  • 2
  • 8
51

I was having the same problem as you. Neither pairing by QR nor by pairing code worked.

So I tried connecting by typing adb connect [phone_ip]:[port] in the terminal and that worked flawlessly. Didn't even need to plug the phone into the computer with a USB. Your phone will tell you the IP and port right above the "pair with QR code" option inside the Wi-Fi debugging setting. Just connect to that address.

Rahul
  • 3,293
  • 2
  • 31
  • 43
VIBrunazo
  • 1,340
  • 14
  • 21
32

Go to Settings -> Build, Execution... -> Debugger -> Built-in Server

and in the Built-in Server option set the value of Port as the same port you see in your phone and tick the Can accept external connections

after that go to wireless pairing and your device will show now

Rahul
  • 3,293
  • 2
  • 31
  • 43
Rishabh Mehta
  • 427
  • 3
  • 2
12

I tried everything to fix this and nothing worked. In frustration, I went for a walk. When I came back - it worked.

So while I can't say for sure what fixed it, try turning your phone's WiFi off then on again.

Slbox
  • 10,957
  • 15
  • 54
  • 106
7

Enable wifi debug on your phone.

Then write in terminal of android studio: Navigate to platform-tools

cd %LOCALAPPDATA%\Android\sdk\platform-tools

and then:

./adb pair [192.xxx.xxx.xxx]:[xxxxx] the data you get from pair with code tab

Press enter.

Then type your pair password.

Then

./adb connect [192.xxx.xxx.xxx]:[xxxxx] your data from pair via wifi

If not working again just restart phone and try again

mikelantzelo
  • 182
  • 1
  • 9
  • The moment the device showed up for me in Android Studio was after the `adb pair` command. I also added the `adb` to the parth variables to make sure Android Studio could execute it. Then fill in the code in Android Studio. Then it said `Connecting to device` and that the paring could take up to 2 minutes. I wonder if that dialog will ever end... And, it didn't connect saying there was an issue :( – Mike de Klerk Nov 11 '22 at 10:52
4

It may be worth your while to ensure:

  1. The relevant API is installed in Android Studio (either 30 or 31/"S" since this is a feature only available on phones running Android 11 and up).
  2. adb.exe is not blocked by your system's firewall (on Windows, check this in Windows Security > Firewall and network protection > allow an app through firewall).
  3. The latest build-tools are installed, as mentioned in the comments.

After that, the connection wizard at least recognized my device (Samsung Note 10), but failed to connect and gave a generic error message. I avoided this by using adb pair <ip-address>:<port> <code> as mentioned in this answer. Seems like this feature still has a ways to go.

gorilla_glue
  • 315
  • 2
  • 13
2

In my case, I have a galaxy s10e, and I need to put my phone in charge and activate wifi debugging and when it's connected with android studio, I can unplug the phone and it still works. In Huawei there is an option in developer options "Allow ADB debugging in load only mode", we can disable it and it works without charging the phone. On s10e there is no such option, I think that it is allowed by default and we can't change it.

Rahul
  • 3,293
  • 2
  • 31
  • 43
Loïc Jackotin
  • 563
  • 3
  • 12
2

I periodically get this problem (Pairing Android Studio on my Mac to Android Phone, the Computer just hangs after phone scans QR code). When I disable and then re-enable wifi debugging on the Android phone, it connects on the next attempt.

Peter
  • 12,274
  • 9
  • 71
  • 86
1

I have reinstalled platform-tools and it helped.

Kamil
  • 13,363
  • 24
  • 88
  • 183
1

open terminal and type cd %LOCALAPPDATA%\Android\sdk\platform-tools ./adb connect <device_ip>:<device_port>

0

I was having the same problem. QR Code, Pairing code, or even connecting manually with the "adb connect [phone_ip]:[port]" method didn't work. However, the problem was solved as soon as I disabled the "AP isolation" option on the modem settings.

Rahul
  • 3,293
  • 2
  • 31
  • 43
Deniz Cetin
  • 1
  • 1
  • 3
0
  1. Turn off and turn on Wi-Fi on your phone.
  2. Ping the phone firstly: ping 192.168.1.97. You should see that packets are transmitted.
  3. Now you highly likely can connect to the phone using QR-code or adb pair
James Bond
  • 2,229
  • 1
  • 15
  • 26
  • 1
    What exactly does "Ping the phone firstly: ping 192.168.1.97" mean? Can you (or anyone) please tell me the steps? – Karolina Hagegård Jun 26 '22 at 15:53
  • 1
    @KarolinaHagegård You should run a `ping` command with the ip of your device. The purpose of this action is to check that your device is available within your wi-fi network. For unknown reasons, a phone can "disappear" from the network. When your turn off and turn on wi-fi, you force you phone to became visible withing the network. Using `ping` command you just check that your device is visible for another computers withing the wi-fi network. – James Bond Jun 26 '22 at 20:39
  • 1
    And how do I run this `ping` command, please? – Karolina Hagegård Jun 27 '22 at 19:58
  • 1
    @KarolinaHagegård this is a command that you type in a linux/windows/mac terminal. Try to google about it... – James Bond Jun 29 '22 at 16:25
  • 2
    I HAVE googled about it, and that's how I ended up on this page... ‍♀️ And I'm sure many other people will also google and end up here, because if you haven't noticed, StackOverflow pages tend to come up first in google searches! And for a good reason, because other SO users usually tell you exactly how to solve your problem. Step by step, and with exact terminal commands written down. That's what this forum is for. Too bad you are not equally helpful! – Karolina Hagegård Jun 29 '22 at 16:35
0

Try to update SDK Platform-Tool and Build-tools.

Razz
  • 452
  • 6
  • 9
0

I was able to get it to pair (Windows 11), by doing this:

  1. Disable wireless debugging on the Android device
  2. Toggle the computer's WiFi off/on
  3. Re-enable wireless debugging
  4. Click "Pair using Wi-Fi" in Android studio
levi
  • 23,693
  • 18
  • 59
  • 73
0

My problem was with the file "devices.xml" located in $USER_FOLDER/.android I have renamed it and the problem goes.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33650187) – V-rund Puro-hit Jan 24 '23 at 09:14
0

The first thing I tried was restarting wifi & it worked. I didn't try other solutions though! So for those, who didn't get the answer, you can try restarting wifi.

Kavita Patil
  • 1,784
  • 1
  • 17
  • 30