Get application version name using adb

2020-05-11 10:26发布

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 adb
5条回答
\"骚年 ilove
2楼-- · 2020-05-11 11:11
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\]"
查看更多
聊天终结者
3楼-- · 2020-05-11 11:24

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
查看更多
一纸荒年 Trace。
4楼-- · 2020-05-11 11:29

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
查看更多
仙女界的扛把子
5楼-- · 2020-05-11 11:30

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.

查看更多
做个烂人
6楼-- · 2020-05-11 11:32

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 = ""; } }'
查看更多
登录 后发表回答