Skip to content

Instantly share code, notes, and snippets.

@guysmoilov
Created June 13, 2016 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guysmoilov/e6b39dc9dfad9e1123fb75ef7f284bc2 to your computer and use it in GitHub Desktop.
Save guysmoilov/e6b39dc9dfad9e1123fb75ef7f284bc2 to your computer and use it in GitHub Desktop.
Python script to reinstall an apk
import subprocess
import sys
import re
apkpath = sys.argv[1]
print('checking packagename')
head = subprocess.check_output('aapt d badging "' + apkpath + '"').decode("utf-8").split("\n")[0]
packagename = re.match(r'^package: name=\'([A-Za-z0-9\.]+)\'', head).group(1)
print('uninstalling ' + packagename)
subprocess.check_call("adb uninstall " + packagename)
print('installing ' + apkpath)
subprocess.check_call('adb install "' + apkpath + '"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment