Skip to content

Instantly share code, notes, and snippets.

@Khip01
Created September 2, 2025 04:06
Show Gist options
  • Save Khip01/e832aa6eefbdd5e06b637f8cc218da3c to your computer and use it in GitHub Desktop.
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.
#!/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