Get Android .apk file VersionName or VersionCode WITHOUT installing apk
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
final PackageManager pm = getPackageManager();String apkName = "example.apk";String fullPath = Environment.getExternalStorageDirectory() + "/" + apkName; PackageInfo info = pm.getPackageArchiveInfo(fullPath, 0);Toast.makeText(this, "VersionCode : " + info.versionCode + ", VersionName : " + info.versionName , Toast.LENGTH_LONG).show();
If you are using version 2.2 and above of Android Studio then in Android Studio use Build → Analyze APK then select AndroidManifest.xml file.