Get an APK's versionName or versionCode without installing it
Codemia Knowledge Hub ·
You can read an APK's versionName and versionCode without installing it, because both are stored in the APK's AndroidManifest.xml. The usual tool is AAPT (Android Asset Packaging Tool) from the Android SDK, which reads that metadata straight from the .apk file.
versionName vs versionCode
An .apk (Android Package) file contains the app's code, resources and metadata, including two version attributes defined in AndroidManifest.xml:
- versionName: a human-readable string (for example
1.0.0) that usually follows the major.minor.patch convention. - versionCode: an integer for the version of the app code. It only increases, so newer versions get higher numbers, which tools like the Google Play Store use to decide update eligibility.
Knowing these lets developers and users track updates, maintain compatibility and manage dependencies.
Reading the version with AAPT
AAPT is part of the Android SDK and is designed to handle the contents of .apk files, including extracting versionName and versionCode.
- Install the Android SDK Build Tools, which include
aapt, through the SDK Manager or by downloading the tools directly. - Locate the APK file you want to inspect.
- Run
aaptagainst the APK to extract the version details. It lives inandroid_sdk/build-tools/<version>/:
The first line of the output carries both values:
aapt2 dump badging path/to/app.apk works the same way with the newer AAPT2.
Online APK analyzers
Some online services display an APK's metadata, including version codes, after you upload the .apk file.
Security and automation
- Security: make sure you have the right to analyze the
.apk, especially with online services, since uploading can expose the file to risks. - Automation: these techniques can run in CI/CD pipelines to extract and validate version information before deployment.
- Parsing output: script around the command-line output for automated or batch workflows.
Related reading
- Get Android Device Name
- Get Android Phone Model programmatically , How to get Device name and model programmatically in android?
- Get application version programmatically in android
- Get Bitmap attached to ImageView
- Get boolean from database using Android and SQLite
- Get button click inside UITableViewCell
- Get class name of object as string in Swift
- Get content uri from file path in android
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.