Read less information about apk file with aapt tool
Here's a trick that works like a charm for me. I am using Backtrack 5 r2; GNU bash version 4.1.5 (1) -release (i486-pc-linux-gnu)
Assuming the executable is. / aapt is in the same shell or script directory. If not just add the path to the executable or use the export aapt = "/ path / to / aapt" and use the variable path.
out = $ (./ aap dump badging GameCIH.apk | grep 'application-label:' | awk -F: 'match ($ 0, ":") {print substr ($ 0, RSTART + 1)}' | tr -d "'")
From tag-app: 'GameCIH' on apk
Only:
GameCIH
Last thing. If you want a package name or version name, do the following:
out = $ (./ aap dump badging GameCIH.apk | grep 'versionName =' | awk -F: 'match ($ 0, "versionName =") {print substr ($ 2, RSTART-8)}' | tr - d "'")
This will return for example:
versionName = 3.0.0
Just change the versionName values to whatever you need.
Change RSTART-8 to something like this: RSTART + 4 and it will return:
3.0.0
Hope this helps!
source to share
aapt d badging myapk.apk | grep package
for Windows, download UnxUtils to get grep command and more Linux: http://unxutils.sourceforge.net/UnxUtils.zip
source to share
Here's the Bash function:
# Display package name and version of APK file(s)
apk(){
(
set -o pipefail
for path in "$@"; do
aapt dump badging "$path" \
| awk $'
BEGIN {
p=""
v=""
}
match($0, /^package: name=\'([^\']*)\'/, a) {
p=a[1]
}
match($0, /versionName=\'([^\']*)\'/, b) {
v=b[1]
}
END {
if (length(p) && length(v)) {
print p, v
}
}'
done
)
}
source to share