Create a gist now

Instantly share code, notes, and snippets.

anonymous /
Created May 16, 2013

What would you like to do?
A short script to perform auto install on multiple Android devices by watching a specific folder for an .apk write. Usage: ./ com.example.package/.MainActivity
inotifywait -m -q -e close_write "$folder" | while read f; do
# take only the filename
f=`awk '{print $3}' <<< "$f"`
# rebuild the full path
# if it's not an apk or is the unaligned one, skip it
if [[ $f =~ ^.*unaligned\.apk$ || ! $f =~ ^.*apk$ ]]; then
echo "Skipping $f"
# Get the list of device names. This ignores whether they're online or not.
devices=`adb devices | sed '1d' | awk '{print $1;}'`
echo "Sending $f.."
echo "$devices" | (parallel adb -s {} install -r "$path" | sed 's/^/ /') 2> /dev/null
echo "done"
# If we provided an activity name, start it on all devices
if [ $package ]; then
echo "Starting activity $package.."
echo "$devices" | (parallel adb -s {} shell am start "$package" | sed 's/^/ /') 2> /dev/null
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment