Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 11+ Wireless Debugging not available when using Mobile Hotspot as the network

Before android 11, i was able to wirelessly debug apps using this method

  1. turn on the mobile hotspot in the (target) android phone
  2. connect the computer to the hotspot
  3. run adb tcpip 5555
  4. adb connect [ip of the target phone]

The problem is Android 11 introduced Wireless Debugging and the above method doesn't work as expected. And the wireless debugging mode cannot be turned on unless my android phone is connected to wifi so it is not working because I want to use the target phone's hotspot for wireless debugging.

is there any possible solution? or is it possible to turn the wireless debugging mode ON even if the phone is not connected to wifi?

like image 613
Nasib Avatar asked Nov 29 '25 20:11

Nasib


2 Answers

Since other answers skip a couple of crucial steps, here is what really worked for me:

  1. Enable USB debugging in the phone settings
  2. Connect phone to PC with a USB cable. Make sure the phone recognizes it as a data connection
  3. Make sure debugging over USB is working for you. Follow the troubleshooting guides from Google if necessary
  4. I'm assuming the adb command is working from a terminal on your PC. If not, follow the official setup guides from Google
  5. On your PC run in the terminal: adb tcpip 5555
    • Should return restarting in TCP mode port: 5555
  6. Disconnect phone from USB and connect PC to phone's HotSpot
  7. In phones settings it lists its IP address. For me it was under System>About Phone>Status>IP address. Let's say it is 100.100.100.1
  8. On your PC run adb connect 100.100.100.1:5555
    • Should return connected to 100.100.100.1:5555
  9. Android Studio should have your phone in the list of devices, no need to add it in any other way

Instructions from here

like image 109
voddan Avatar answered Dec 02 '25 08:12

voddan


Work Around

  1. run adb tcpip 5555
  2. run adb connect [ip]
  3. for android 11 and 12 go to Settings/Display & brightness/Auto screen off and make it 30 minutes. (means that your phone won't auto lock so it will stay wirelessly connected to ADB)

- android 13 and above do not disconnect you if your device gets locked

- I hope android engineers will allow using the wireless debug feature without being connected to WiFi in newer versions of android though, as pointed to in the question.

Bonus info:

Your phone has two ip addresses, one from your Internet Provider (in Settings/About/Status) that changes whenever you turn off your Mobile Data and one that your hotspot creates as a router (you can get it from your PC when you connet to your phone's hostpot) that does not change (sometimes does change if you restart your phone, though

macOS: after step 1 above, if you run netstat -nr | grep default you will get the router's (Your phone in this case) ip address in the first line 'default gateway' (For windows ipconfig in cmd)


Mac only

I also made aliases for the terminal

alias adb_s='adb tcpip 5555'
alias adb_sc='adb tcpip 5555 && adb connect $(netstat -nr | grep default | awk '\''$2 ~ /\./ {print $2}'\'')'
alias adb_c='adb connect $(netstat -nr | grep default | awk '\''$2 ~ /\./ {print $2}'\'')'

Now, when i run (single command):

adb_sc = device starts in tcpip mode and gets connected wirelessly 
adb_c = device gets connected wirelessly if already in tcpip mode
adb_s = device starts in tcpip mode

You can copy the aliases above into .zshrc {/Users/[your-username]/.zshrc (for zsh terminal)} file and can enjoy the convenience as well.

like image 28
Nasib Avatar answered Dec 02 '25 10:12

Nasib



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!