Find versionnumber and versioncode of apk generated by android studio

Husein Behboodi Rad picture Husein Behboodi Rad · Jul 27, 2014 · Viewed 13k times · Source

I know that .apk files are zip files and when we extract them can parse manifest file inorder to finding some information about the app. It is very useful for someone like me that is going to create an app-store. Actually at least I can find the version name and version code of the app.

But in the android-studio when we build a signed apk the version name and version code is not defining in the manifest file. We should define them in the build.gradle file. So now in my app-store when users upload the files how can I find the version code and version name and detect that is not same with old versions?

Answer

Martin Revert picture Martin Revert · Jul 27, 2014

Just use AAPT from your path/to/your/android-sdk/build-tools/your-api-version-available/...

An example of the command execution:

aapt dump badging theuserapp.apk

And it will respond with something like:

package: name='com.blabla.theuserapp' versionCode='2000' versionName='2.0.0'

Of course, as the tool is an executable which produces a raw text output you can easily script it and parse from your favorite scripting languaje.