Last active
October 11, 2017 16:59
-
-
Save horacioh/288ef2ebd0319007a7f9 to your computer and use it in GitHub Desktop.
Uninstall & Install and app using adb on multiple devices connected via USB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uninstallApp { | |
echo "===== Uninstalling "$PACKAGE_NAME" on target "$1 | |
adb -s $1 shell pm clear $PACKAGE_NAME | |
adb -s $1 uninstall $PACKAGE_NAME || { exit -3; } | |
} | |
function updateAndLaunchApp { | |
echo "===== Installing "$PACKAGE_NAME" on target "$1 | |
adb -s $1 install -r cordova/platforms/android/ant-build/$APP_NAME-debug.apk || { exit -4; } | |
echo "===== Launching "$PACKAGE_NAME" on target "$1 | |
adb -s $1 shell monkey -p $PACKAGE_NAME -c android.intent.category.LAUNCHER 1 || { exit -5; } | |
} | |
# create an array of all devices connected via USB | |
deviceLst=$(adb devices | awk 'NR > 1 {print $1}' | sed ':a;N;$!ba;s/\n/ /g') | |
# loop through the array of devices | |
for d in $deviceLst | |
do | |
uninstallApp $d | |
updateAndLaunchApp $d | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment