Get Android .apk file VersionName or VersionCode WITHOUT installing apk

Big.Child picture Big.Child · Nov 20, 2012 · Viewed 128.3k times · Source

How can I get programmatically get the version code or version name of my apk from the AndroidManifest.xml file after downloading it and without installing it.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxx.xx.xxx"
    android:versionCode="1"
    android:versionName="1.1" >

For example I want to check if a new version is uploaded on my IIS service, after install it on device, if it is not a new version I don't want to install it.

Answer

Sileria picture Sileria · Aug 13, 2014

Following worked for me from the command line:

aapt dump badging myapp.apk

NOTE: aapt.exe is found in a build-tools sub-folder of SDK. For example:

<sdk_path>/build-tools/23.0.2/aapt.exe