18

I want to read the requested permissions of an .apk file on the computer (android sdk is installed) via command line.

I.E.:

$ android read-permissions /path/to/someapp.apk

I know this is possible, I just cant find the proper command.

Izzy
  • 91,166
  • 73
  • 343
  • 943
whlk
  • 393
  • 1
  • 2
  • 7

2 Answers2

29

If I'm interpreting "on the computer" correctly to mean "I want to use the command line on my computer to read an .apk file's permissions" then you can do that with aapt on a local file like so:

C:\>aapt d permissions "MyApp.apk"
package: com.app.myapp
uses-permission: android.permission.ACCESS_NETWORK_STATE
uses-permission: android.permission.INTERNET

If you mean that the .apk is on the device, then I'm not aware of a way to do this aside from pulling it and running aapt as above. pm has a list permissions command but it just lists all available permissions on the device and does not accept a package as a parameter (as far as I know, anyway).

eldarerathis
  • 36,787
  • 16
  • 144
  • 175
  • If you are on Mac, you will have to get the path to your aapt, based on the build-tools for Android, something like this, just change the placeholders for your username (of the Mac), build-tools version and path to the APK you want to test:

    sudo /Users/YOUR_USER_NAME/Library/Android/sdk/build-tools/BUILD_TOOLS_SDK_VERSION/aapt d permissions 'path_to_the_apk_file'

    – Henrique Aron Apr 13 '23 at 17:35
1

On the device it will probably be easier to look for the relevant section in

/data/system/packages.xml

(which can be read, even though its directory cannot be browsed or listed) as this is a text file, while the AndroidManifest.xml in an apk is in a compressed format.

There is code around on the net for interpreting the compressed manifests on the device, but that's a bit more complicated.

Chris Stratton
  • 1,699
  • 13
  • 13