Member-only story

How to read version and other information from Android and iOS apps using Java

Easily retrieve version information from APK, IPA, and APP packages

Martin Schneider
Better Programming
4 min readNov 19, 2018
Photo: Maurizio Pesce/flickr

Many times, especially when running automated tests against mobile apps, it is important to verify that the correct version of an app is used. This article describes easy ways to query the version information from both Android and iOS app packages using either command line tools or Java libraries. Both approaches can be easily integrated into a build pipeline.

The command-line way

For Android, one approach to parse meta information from an APK file is to use aapt like this:

aapt dump badging /path/test.apk

This prints a lot of information so we need to trim the output to what we are interested in:

aapt dump badging test.apk | grep -o 'versionName=[^,]*' | cut -d'=' -f 2 | cut -d ' ' -f 1 | tr -d "'"

Similarly, we can also query the version code (or any other information for that matter):

aapt dump badging /path/test.apk | grep -o ‘versionCode=[^,]*’ | cut -d’=’ -f 2 | cut -d ‘ ‘ -f 1 | tr -d "'"

If we have the app installed on a device (physical or simulator) which is connected via adb

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (2)

Write a response