Skip to content

Instantly share code, notes, and snippets.

@MacRusher
Last active October 3, 2018 12:13
Show Gist options
  • Save MacRusher/7ece5990c0c4548e2acdec144576d35e to your computer and use it in GitHub Desktop.
Save MacRusher/7ece5990c0c4548e2acdec144576d35e to your computer and use it in GitHub Desktop.
Enable remote debugging on android device via ADB over TCP/IP
#!/usr/bin/env bash
# List current devices before operation for convenience
# There must be only one device connected or operation will fail
adb devices
# Listen on TCP port
adb tcpip 5555
# Connection may fail operation if done too early, so wait for a while
sleep 5;
# Find out local ip address (this may differ based on network card etc.) and connect via TCP/IP
adb connect $(adb shell ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'):5555
# Done, you can now unplug usb cable and adb will still work
@MacRusher
Copy link
Author

MacRusher commented Oct 3, 2018

Tested on Ubuntu.

You probably want to change network interface name (wlan0 in my case).
Run ifconfig for more details.

Usage:

  1. Connect android device with usb cable and make sure that ADB is working correctly via the cable.
    • There must be only one device connected, no support for multiple devices yet.
    • Device must be in the same network.
  2. Execute script.
  3. If everything worked you should see something like Connected to xx.xx.xx.xx:5555.
  4. Unplug the USB cable and continue work as usual, but over a WIFI network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment