Get application version name using adb

AndroidAdb

Android Problem Overview


Is there an easy way to get the version name of an application on an Android device using adb shell?

I found the application version number (not the version name) in /data/system/packages.xml.

It would be nice if there was a file that contained the Application Info.

Android Solutions


Solution 1 - Android

adb shell dumpsys package my.package | grep versionName

as mentioned by @david and @Jeremy Fishman. This will be much quicker than:

adb shell dumpsys | grep -A18 "Package \[my.package\]"

Solution 2 - Android

Dumpsys package is your friend

~/# adb shell
shell@mo:/ dumpsys package tld.comp.app_name | grep version


Will return

versionCode=X targetSdk=YY
versionName=Z.Z

Solution 3 - Android

In case someone needs all apps versions for comparing purposes then here is my oneliner:

for p in `adb shell pm list package | awk -F"package:" '{print $2}'`; do echo -n "$p: "; adb shell dumpsys package $p | grep -i versionName | awk -F"=" '{print $2}'; done

Maybe it will be helpful for somebody but please note that I use versionName and ignore versionCode, so use with care.

Solution 4 - Android

If you want to get all package versions, try this awk script:

adb shell dumpsys package | awk '/^[ ]*Package \[.*\] (.*)/ { i = index($0, "[") + 1; pkg = substr($0, i, index($0, "]") - i); } /[ ]*versionName=/ { { print pkg "\t" substr($0, index($0, "=") + 1); pkg = ""; } }'

Solution 5 - Android

If you don't want install *.apk on device but you need get version of app, you can do it as follow

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfrognosisView Question on Stackoverflow
Solution 1 - AndroidarbuzView Answer on Stackoverflow
Solution 2 - AndroidMonoThreadedView Answer on Stackoverflow
Solution 3 - AndroidLLLView Answer on Stackoverflow
Solution 4 - Androiduser541686View Answer on Stackoverflow
Solution 5 - AndroidSergeyYuView Answer on Stackoverflow