Search code examples
androidadbversionandroid-manifest

Adb command to get versionCode from apk


Is there an adb command to run on a .apk which gives me the android:versionCode that is set in the AndroidManifest file of that apk?

Basically, how do I get the version code of the apk using adb?


Solution

  • For Version Name :

    adb shell dumpsys package my.package | grep versionName
    

    For Version Code :

    adb shell dumpsys package my.package | grep versionCode
    

    Also you can try this below too:

    Android: Get versionName or versionCode of an APK from the command line You can use aapt in android's build-tools directory of whatever build tools version you're using.

    You pass that tool the badging command, and then pass it the location of your APK.

    Example:

    $ANDROID_HOME/build-tools/24.0.2/aapt dump badging app/build/outputs/apk/app-release.apk
    

    If you scroll through all the output, you can find the versionName and versionCode.