| name | android-adb-debug |
| description | Linux→Windows AndroidエミュレータへのADBデバッグ。スクリーンショット、ログ取得、UI操作、アプリインストールなど。 |
| allowed-tools | Bash, Read, Write |
Android ADB Debug
LinuxからWindows上のAndroidエミュレータをADB経由でデバッグするスキル。
前提条件
adb-connection-troubleshoot の初回セットアップが完了していること
- Windows側でエミュレータが起動していること
.env.local に WINDOWS_IP=100.x.x.x が設定されていること
クイックスタート
ビルド & インストール
./.claude/skills/android-adb-debug/scripts/linux_connect_and_install.sh
接続 → ビルド → インストール → アプリ起動を一括実行。
ADBコマンドリファレンス
接続情報
DEVICE="100.x.x.x:5559"
スクリーンショット
注意: 画像を Read ツールで表示するのは時間がかかるため、デバッグには向きません。
VS Code で /tmp/screen.png を直接開くか、uiautomator で UI 状態を確認してください。
adb -s $DEVICE shell screencap /sdcard/screen.png
adb -s $DEVICE pull /sdcard/screen.png /tmp/screen.png
ログ取得
adb -s $DEVICE logcat -d -t 50
adb -s $DEVICE logcat -d "*:E" | tail -30
adb -s $DEVICE logcat -b crash -d -t 200
adb -s $DEVICE logcat -s EgoGraph:* | tail -50
PID=$(adb -s $DEVICE shell pidof dev.egograph.app)
adb -s $DEVICE logcat -d --pid=$PID | tail -50
アプリ操作
adb -s $DEVICE shell am start -n dev.egograph.app/.MainActivity
adb -s $DEVICE shell am force-stop dev.egograph.app
adb -s $DEVICE shell am force-stop dev.egograph.app && \
adb -s $DEVICE shell am start -n dev.egograph.app/.MainActivity
adb -s $DEVICE uninstall dev.egograph.app
UI操作
要素の座標を特定する (uiautomator) - 推奨
座標を推測するのではなく、UI 階層から正確な座標を取得します。
adb -s $DEVICE shell uiautomator dump
adb -s $DEVICE pull /sdcard/window_dump.xml /tmp/ui.xml
cat /tmp/ui.xml | grep 'text="Save"'
cat /tmp/ui.xml | grep 'text="Send"'
cat /tmp/ui.xml | grep 'resource-id="dev.egograph.app:id/save_button"'
adb -s $DEVICE shell uiautomator dump && \
adb -s $DEVICE pull /sdcard/window_dump.xml - && \
BOUNDS=$(grep -o 'bounds="\[[0-9]*,[0-9]*\]\[.*?\]' /tmp/ui.xml | head -1 | \
sed 's/bounds="\[\([0-9]*\),\([0-9]*\)\[.*\]"/\1 \2/') && \
adb -s $DEVICE shell input tap $BOUNDS
座標指定でタップ(上記で特定した座標を使用)
adb -s $DEVICE shell input tap 540 1200
adb -s $DEVICE shell input text "hello"
adb -s $DEVICE shell input keyevent 66
adb -s $DEVICE shell input keyevent 4
adb -s $DEVICE shell input keyevent 3
adb -s $DEVICE shell input swipe 540 1500 540 500 300
状態診断
adb -s $DEVICE shell ps -A | grep egograph
adb -s $DEVICE shell dumpsys meminfo dev.egograph.app
adb -s $DEVICE shell dumpsys activity activities | grep -A 5 "dev.egograph"
adb -s $DEVICE shell pm list packages | grep egograph
ファイル操作
adb -s $DEVICE pull /sdcard/Download/file.txt ./file.txt
adb -s $DEVICE push ./file.txt /sdcard/Download/file.txt
adb -s $DEVICE shell ls -la /sdcard/
APK操作
adb -s $DEVICE install -r ./app-debug.apk
adb -s $DEVICE install -r -d ./app-debug.apk
デバッグワークフロー
1. 画面確認
DEVICE="100.x.x.x:5559"
adb -s $DEVICE shell screencap /sdcard/screen.png
adb -s $DEVICE pull /sdcard/screen.png /tmp/screen.png
2. エラー調査
adb -s $DEVICE logcat -d "*:E" | tail -50
adb -s $DEVICE logcat -d | grep -E "FATAL|Exception|Error" | tail -30
PID=$(adb -s $DEVICE shell pidof dev.egograph.app)
adb -s $DEVICE logcat -d --pid=$PID | tail -50
3. 操作テスト
adb -s $DEVICE shell am force-stop dev.egograph.app
adb -s $DEVICE shell am start -n dev.egograph.app/.MainActivity
sleep 2
adb -s $DEVICE shell screencap /sdcard/screen.png
adb -s $DEVICE pull /sdcard/screen.png /tmp/screen.png
関連スキル
| スキル | 用途 |
|---|
adb-connection-troubleshoot | 接続問題のトラブルシューティング |
追加リファレンス
- WebView DOM デバッグ手順:
references/webview-dom-debug.md