| name | android-clipboard |
| description | Use this skill when an agent needs to set text on a connected Android device clipboard through ADB, especially when cmd clipboard is unavailable and service call cannot pass ClipData on modern Android versions. |
Android Clipboard
Set Android device clipboard text from an agent host through ADB.
Use this skill when the user asks to copy text, commit messages, logs, commands, or other generated content to a connected Android phone or emulator clipboard.
Quick Start
Use the bundled script from the skill root:
scripts/set_android_clipboard.sh "text to copy"
For multi-line content, pipe stdin:
printf '%s' "$text" | scripts/set_android_clipboard.sh --stdin
For a specific device:
scripts/set_android_clipboard.sh --device "$ANDROID_SERIAL" --stdin < message.txt
If the host has ADB outside PATH, pass it explicitly:
scripts/set_android_clipboard.sh --adb "/path/to/adb" --stdin < message.txt
Workflow
- Resolve ADB first. Prefer
--adb /path/to/adb when the path is known. Otherwise let the script search $ADB, PATH, common Android SDK locations, Homebrew, and /usr/local/bin.
- Confirm the resolved ADB sees exactly one usable device, or pass
--device SERIAL.
- Prefer
scripts/set_android_clipboard.sh; it uses the bundled dex helper and avoids shell quoting issues by base64-encoding the text.
- Always use the prebuilt
bin/set-android-clipboard.dex for runtime clipboard writes. Rebuild with scripts/build_helper_dex.sh only when the dex is missing or the Java helper source changed.
- The script pushes the helper dex to
/data/local/tmp, runs it with app_process, and removes the pushed dex unless --keep-device-dex is used.
scripts/build_helper_dex.sh is only for maintaining the bundled dex from Java source. Routine clipboard writes should not need Android SDK tools beyond ADB.
- Report failure plainly when no device is connected, multiple devices are connected without
--device, ADB is unavailable, or Android blocks clipboard access.
Why app_process
Modern Android clipboard APIs require a real ClipData Parcelable. Plain adb shell service call clipboard ... s16 ... is not reliable for setting text. dalvikvm can run simple dex commands, but framework services such as clipboard may fail because AndroidRuntime native registration is not initialized. The helper therefore runs through app_process.
Files
scripts/set_android_clipboard.sh: main entry point for agents.
scripts/build_helper_dex.sh: maintenance script that rebuilds the dex from Java source.
src/main/java/com/agenttools/androidclipboard/SetAndroidClipboard.java: helper source.
bin/set-android-clipboard.dex: prebuilt helper dex.