Android - Obtain package name AND common name of apps via ADB

Here is my solution for a non-rooted phone which needed some slight changes from above which I ran on a Moto G 2nd gen running android 5.0.2.

I didn't have aapt binary in /system/bin, so I first tried downloading from:

but when I tried to run it I got an error saying:

error: only position independent executables (PIE) are supported.

So then I searched for a PIE version and found:

and this worked by copying binary to /data/local/tmp:

adb push aapt-arm-pie /data/local/tmp
adb shell chmod 0755 /data/local/tmp/aapt-arm-pie

So then:

adb shell pm list packages -3 -f

gets list of 3rd party apps (apps you have installed, not system apps) and then you can use package from command above in aapt to get information on package - example:

adb shell /data/local/tmp/aapt-arm-pie d badging /data/app/com.facebook.katana-3/base.apk

So below is script (for a Linux client) to get just "common" name for 3rd party apps:``

for pkg in `adb shell pm list packages -3 -f | awk -F= '{sub("package:","");print $1}'`
  adb shell /data/local/tmp/aapt-arm-pie d badging $pkg | awk -F: '
      $1 == "application-label" {print $2}'

If you want package and version too, then change last but one line from:

$1 == "application-label" {print $2}'


$1 == "package" { split($2,space," ")
$1 == "application-label" {print name, version, $2 }'

Example output:

name='com.ultimarom.launchnavigation' versionName='1.28' 'Navigation' name='com.enhanced.skineditorstudio' versionName='3.3' 'Custom Skin Creator' name='com.mojang.minecraftpe' versionName='' 'Minecraft' name='org.videolan.vlc' versionName='2.5.13' 'VLC' name='com.jrustonapps.myauroraforecast' versionName='1.7.2' 'My Aurora Forecast' name='de.j4velin.wifiAutoOff' versionName='1.7.6' 'WiFi Automatic' name='com.facebook.katana' versionName='' 'Facebook' name='com.metago.astro' versionName='6.0.5' 'ASTRO File Manager' name='' versionName='2.0.2' 'My 5krun' name='com.PYOPYO.StarTrackerVR' versionName='1.0.1' 'StarTracker VR' name='cz.aponia.bor3.offlinemaps' versionName='1.1.19' 'Offline Maps' name='com.groupon' versionName='16.11.63973' 'Groupon' name='' versionName='' 'eBay' name='' versionName='8.1.1' 'Runtastic' name='' versionName='3.8.3' 'DiskUsage'


This is not a final answer, as it is not generic (only works on some devices) – but it's a start at least:

As we've figured out, at least CM based ROMs with Kitkat (Android 4.4) and above ship with the aapt binary available in /system/bin1. If your ROM doesn't have it, and installing the binary on the device is an option, you can find it here.

Using aapt, retrieving the app name is possible with

aapt d badging <path to apk> | grep "application: label" |awk '{print $2}'

The output will be something like label='Funny App', which you then easily can parse for the app name, e.g.

aapt d badging <path to apk> | grep 'application: label' | sed -n \"s/.*label\='\([^']*\)'.*/\1/p\"

(not good if the app name contains single quotes, but that might count as cosmetics – or you figure how to improve the sed part to deal with that).

1: we didn't find this in the Kitkat-and-above stock ROMs we've checked, so it might be CM based ROMs only