3

I found several isntructions to activate ADB over wireless network instead USB connection (like this) but I have a problem: my device has the USB port broken.

I cannot execute adb tcpip 5555 because that, so I need to activate ADB over wireless if I want to use ADB to control the device.

Is there any way to do that without rooting the device? I tried several commands on a terminal emulator, but I didn't accomplish my objective.

Any proposal on that?

JoseLSegura
  • 3,830
  • 3
  • 20
  • 27
  • Possible duplicate of [How can I connect to Android with ADB over TCP?](https://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp) – Zoe Dec 18 '17 at 08:52
  • maybe check `adb tcpip` with another number - like `6789` – STF Jan 04 '18 at 07:59
  • Which version of android is ruuning on your phone/device? – OneDev Jan 28 '22 at 05:23
  • Go to Developer Options, if there is a menu named wireless debugging, turn it on, after that tap one it go to the wireless debugging menu, click on pair device with pairing code, open cmd and type **adb pair 192.168.xx.xx:xxxxx ** replace x with your phone address and port, after that you must see a success message, in the cmd type ip address and port you see in wireless debugging menu, type **adb connect 192.168.xx.xx:xxxxx** and hit enter, you must get a message that successfully connected – OneDev Jan 28 '22 at 05:32
  • If your phone doesn't have wireless debugging menu, there are some plugin exist for android studio, just search for wifi adb, and install one of them, connect your phone with wireless, but i don't guarantee this method would work. – OneDev Jan 28 '22 at 05:36
  • Notice that, both your phone and your computer must be connected to the same wifi – OneDev Jan 28 '22 at 05:38

3 Answers3

0

I have managed to do this using ssh with the following script. It might require some small adjustments (our platform is using systemctl, for one, so you might need to change those calls).

#/bin/bash

if ! command -v sshpass &> /dev/null
then
    echo "sshpass could not be found. Please install it by running 'sudo apt install sshpass'"
    exit
fi

IP="192.168.0.111"
USERNAME="user"
PASSWORD="password"

if [ $1 -a $1 == "disable" ]
then
    read -n 1 -s -r -p "To disable adb over WiFi please plug in the USB cable and press any key."
    adb disconnect $IP
    adb kill-server
    sshpass -p $PASSWORD ssh -o StrictHostKeyChecking=no $USERNAME@$IP "setprop service.adb.tcp.port -1; systemctl stop adbd; killall adbd &>/dev/null; systemctl start adbd &>/dev/null"
else
    read -n 1 -s -r -p "To enable adb over WiFi please unplug USB cable and press any key."
    adb kill-server &>/dev/null
    sshpass -p $PASSWORD ssh -o StrictHostKeyChecking=no $USERNAME@$IP "setprop service.adb.tcp.port 5555; systemctl stop adbd; killall adbd; systemctl start adbd &>/dev/null"
    adb kill- &>/dev/null
    adb connect $IP &>/dev/null
fi

echo "Done!"
Jeremiah Rose
  • 3,865
  • 4
  • 27
  • 31
0

If your device is running Android 11 or above then you can accomplish this without initially needing to connect the phone to PC via USB as mentioned in the official Android developer site (link).

If the Android device is running Android 10 or below then there is no straightforward way without initially connecting USB (link).

Sathyajith
  • 3,836
  • 3
  • 15
  • 28
0

Duplicate of Run/install/debug Android applications over Wi-Fi?

Adding to it, if you install Android Studio Bumblebee version and your device OS is 11+, there is a direct option to connect via Android Studio. Here are the steps:

First, Connect your phone and machine on the same wifi network

on Phone:

  1. Go to Developer Options -> Wireless Debugging -> Turn on the switch then tap on text Wireless Debugging
  2. Select Pair device with QR code

on Desktop:

1.Expand this drop down

Expand this drop down

  1. Select Pair

  2. Scan the QR code wait for some time and that's it!

Note: It disconnects frequently, has to be a bug which we should wait to get fixed

nayan dhabarde
  • 1,734
  • 1
  • 19
  • 38