1

Sometimes I have a trouble matching application's package name in /data/data/ or /data/app/*.apk with the user-friendly activity label I see in GUI.

How do I list application packages together with their activities?

Expecting something like this:

$ adb shell list_apps
de.shandschuh.sparserss "Sparse rss"
org.vudroid "VuDroid"
jcpezzullo.statical "StatiCal"
tone.control "Tone Control"
...
2
  • Related: Obtain package name AND common name of apps via ADB (no answer yet)
    – Andrew T.
    Jan 15, 2015 at 1:27
  • 1
    There is workaround using aapt on host: for i in /directory/with/downloaded/apk/files/*.apk; do printf '%s %s\n' "`aapt dump badging \"$i\" | grep application-label:`" "$i"; done
    – Vi0
    Jan 15, 2015 at 1:38

1 Answer 1

0

Based on my answer on the question Andrew linked to, this is what should be in your list_apps script:

for app in $(ls /data/app/*.apk); do
    appname=$(aapt d badging $app | grep 'application: label' | sed -n \"s/.*label\='\([^']*\)'.*/\1/p\")
    pkgname=$(basename $app)
    echo ${pkgname} "${appname}"
done

Run this on your Android device.

  • Requirements: Either a CM based ROM with Kitkat or higher (which seems to ship with the aapt binary) – or a rooted device where you can install aapt onto yourself (find it here; tested with Android 4.1).
  • Known issues: app name most likely gets truncated when it contains a single quote (see sed expression). Not having such one installed here I could not test that.
  • Only lists user apps. Easy to fix by repeating the block for /system/app ;)
6
  • On Samsung Galaxy S 5, ls /data yields opendir failed, Permission denied. Aug 25, 2017 at 11:41
  • 1
    @StéphaneGourichon requirements not met, see first bullet-point: you need to be root for that.
    – Izzy
    Aug 27, 2017 at 15:44
  • fully valid point yet unexpected. Firelord's comment mentions non-root but mentions entering /data also. Yet I remember having used an app that did this without root access. My guess is, there is probably a way to fulfill OP's question on a non-rooted device, perhaps just aapt in another temp location. Aug 28, 2017 at 3:29
  • @StéphaneGourichon you've missed one thing possibly: ls /data requires root, ls /data/app might not. I'm not sure about the permissions on that folder, but I wouldn't wonder if it's readable and executable to each app. Have you checked that? While without root you cannot list the contents of /data, you can cd into it, and also into /data/app. You just cannot list the contents of /data itself. But without access to tha .apk file it doesn't help to place aapt in another location either; the information required is stored in the .apk files.
    – Izzy
    Aug 28, 2017 at 5:37
  • thanks. Yes and no. You're right in that I can cd into /data and /data/app. But ls still fails in both locations, making the whole operation impractical. I expect the app did it via some API which has necessary access. Aug 28, 2017 at 11:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .