Skip to content

Instantly share code, notes, and snippets.

@adduc
Forked from ohadcn/download_apk.sh
Created March 10, 2016 01:20
Show Gist options
  • Save adduc/0a71471f4b5c75aba57f to your computer and use it in GitHub Desktop.
Save adduc/0a71471f4b5c75aba57f to your computer and use it in GitHub Desktop.
#!/bin/sh
if test $# -lt 1 ; then
echo "Usage: download_apk.sh <target-dir>"
exit 1
fi
for LINE in $(adb shell pm list packages -f -3|sed 's/package://g'); do
APK_PATH=$(echo "$LINE" | cut -d'=' -f1)
FILE=$1/$(echo "${LINE}" | cut -d'=' -f2 | sed 's/\r$//').apk
if [ -f "$FILE" ]; then
DEVICE=$(adb shell md5sum $APK_PATH | cut -d' ' -f1)
LOCAL=$(md5sum $FILE | cut -d' ' -f1)
if [ "$DEVICE" = "$LOCAL" ]; then
echo "Skipping $FILE, already have locally."
continue
fi
fi
echo "Pulling $APK_PATH to $FILE ..."
adb pull $APK_PATH $FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment