Created
September 2, 2025 04:06
-
-
Save Khip01/e832aa6eefbdd5e06b637f8cc218da3c to your computer and use it in GitHub Desktop.
A simple Bash script to automatically set up and connect ADB over TCP/IP with Waydroid, designed for Android development and testing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "π Checking Waydroid session..." | |
if [ "$(waydroid status | awk -F':' '/^Session:/ {print $2}' | xargs)" = "RUNNING" ]; then | |
echo "βΉοΈ Waydroid session already running" | |
else | |
echo "βΆοΈ Starting Waydroid session..." | |
nohup waydroid session start >/dev/null 2>&1 & | |
echo "β³ Waiting for Waydroid session to start..." | |
until [ "$(waydroid status | awk '/^Session:/ {print $2}')" = "RUNNING" ]; do | |
sleep 1 | |
done | |
fi | |
echo "β³ Waiting for Android (inside Waydroid) to finish booting..." | |
while [ "$(sudo waydroid shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" != "1" ]; do | |
echo " ... still booting" | |
sleep 2 | |
done | |
echo "β Android inside Waydroid is fully booted!" | |
echo "π₯οΈ Launching Waydroid full UI..." | |
nohup waydroid show-full-ui >/dev/null 2>&1 & | |
echo "π± Configuring ADB inside Waydroid..." | |
sudo waydroid shell <<EOF | |
setprop service.adb.tcp.port 5555 | |
stop adbd | |
start adbd | |
exit | |
EOF | |
WAYDROID_IP=$(waydroid status | awk '/IP address:/ {print $3}') | |
if [ -z "$WAYDROID_IP" ]; then | |
echo "β Failed to detect Waydroid IP address on interface 'waydroid0'." | |
exit 1 | |
fi | |
# adb on a fresh host | |
adb kill-server | |
adb start-server | |
sleep 1 | |
echo "π Connecting ADB to $WAYDROID_IP:5555..." | |
adb connect "$WAYDROID_IP:5555" | |
echo "β Connected devices:" | |
adb devices | |
if adb devices | grep -q "unauthorized"; then | |
echo "β οΈ Device is unauthorized!" | |
echo "π Please check Waydroid screen and tap 'Allow' button on Allow USB debugging window." | |
else | |
echo "π― Waydroid is now ready for ADB operations (install apps, debugging, automation, testing)." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment