-
-
Save dineshmm23/9bf74fa9c18daf98109b9dd50a0c244b to your computer and use it in GitHub Desktop.
Script to extract the android package id (app id) from an android apk file, and another to uninstall an app when you have the apk handy.
This file contains 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
# extract the android package id from a built apk file | |
# usage ./getPackageName.sh <path-to-apk> | |
line=`aapt dump badging "$1" | grep package:\ name` | |
# above returns: | |
# package: name='com.calvium.myapp' versionCode='1' versionName='1.0' | |
if [[ $line =~ name=\'(.+)\'\ versionCode ]]; then | |
echo ${BASH_REMATCH[1]} | |
else | |
echo "Failed to find package name" | |
exit 1 | |
fi |
This file contains 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
_file="$1" | |
[ $# -eq 0 ] && { echo "Usage: $0 APK_FILENAME"; exit 1; } | |
[ ! -f "$_file" ] && { echo "Error: $0 file not found."; exit 2; } | |
here=`pwd` | |
cd $ANDROID_HOME/build-tools | |
cd * # go into ANY folder | |
# get package name from apk | |
line=`./aapt dump badging "$1" | grep package:\ name` | |
cd $here | |
# above returns: | |
# package: name='com.calvium.myapp' versionCode='1' versionName='1.0' | |
if [[ $line =~ name=\'(.+)\'\ versionCode ]]; then | |
packageName="${BASH_REMATCH[1]}" | |
else | |
echo "Failed to find package name" | |
exit 1 | |
fi | |
echo "Package name is $packageName" | |
adb uninstall $packageName || exit 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment