2024-07-02 Update
In the intervening years, I found I need to get the entire XML to query it using XML tools. Here's a (reasonably) foolproof bash/zsh function that will just dump the file XML formatted:
apkmanifest() { (export d=$(mktemp -d) && trap 'rm -rf $d' EXIT && unzip -q $1 -d $d AndroidManifest.xml && (cd $d && zip -q temp.apk AndroidManifest.xml && apktool d temp.apk > /dev/null 2>&1) && cat $d/temp/AndroidManifest.xml) }
You can just paste it into bash then run it like this:
apkmanifest /path/to/your/android.apk
It:
- Creates a temp directory
- unzips just the AndroidManifest.xml (gibberish version)
- zips it back int temp.apk
- Uses apktool to get it back out in an xml form
- Cats it out
- Removes the temp directory
You need zip
, unzip
, apktool
on your path.
Original Answer
In this thread, Dianne Hackborn tells us we can get info out of the AndroidManifest using aapt.
I whipped up this quick unix command to grab the version info:
aapt dump badging my.apk | sed -n "s/.*versionName='\([^']*\).*/\1/p"