Skip to content

Instantly share code, notes, and snippets.

@lucianomlima
Created June 5, 2019 17:57
Show Gist options
  • Save lucianomlima/d2bffb57bf028f9ef5bb7ef109878200 to your computer and use it in GitHub Desktop.
Save lucianomlima/d2bffb57bf028f9ef5bb7ef109878200 to your computer and use it in GitHub Desktop.
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT
adb tcpip $PORT
# Connect to device
adb connect "$IP_ADDRESS:$PORT"
echo "Done!"
}
@pietropr
Copy link

pietropr commented Jun 5, 2019

o device precisa ser rooteado?

@lucianomlima
Copy link
Author

@pietropr no! But need to have Android API 21 and up.

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