Skip to content

Instantly share code, notes, and snippets.

@bryanjhv
Created May 5, 2019 06:40
Show Gist options
  • Save bryanjhv/f5b19a3622b8f1a2f9bcb31c315c3014 to your computer and use it in GitHub Desktop.
Save bryanjhv/f5b19a3622b8f1a2f9bcb31c315c3014 to your computer and use it in GitHub Desktop.
Script to copy apps between android devices.

Installation

cd
mkdir -p apks
wget https://gist.githubusercontent.com/bryanjhv/f5b19a3622b8f1a2f9bcb31c315c3014/raw/copy.sh -O apks/copy
chmod +x apks/copy

Usage

# Edit your packages...
# Connect source device...
apks/copy
# Connect target device...
#!/usr/bin/bash
pkgs=(
com.termux
mark.via.gp
com.termux.api
com.google.android.webview
com.realvnc.viewer.android
)
echo "Cleaning packages..."
cd "${0%/*}"
rm -rf *.apk
echo "Scanning packages..."
for line in $(adb shell pm list packages -f | tr -d '\r'); do
line="${line#*:}"
name="${line#*=}"
full="${line%=*}"
for want in "${pkgs[@]}"; do
if [ "$want" == "$name" ]; then
echo "Downloading $want..."
adb pull "$full" "$name.apk" > /dev/null
fi
done
done
read -p "Waiting for next device..."
echo "Restoring packages..."
for full in $(ls *.apk); do
echo "Installing ${full%.*}..."
adb install -r $full
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment