0

I want to write an android app which can analyse the APK file and output the permissions this application required? I saw some app achieve this and can anyone tell me which method they might used? thanks

Eva
  • 332
  • 2
  • 13

1 Answers1

2

The best way of doing it with external apk files, not the installed ones:

The .apk file is a casual .zip with changed extension. The permissions are located in AndroidManifest.xml file, so your job is to load it into memory, parse with some XML parser and search for uses-permission tag.
It looks like this <uses-permission android:name="android.permission.XXX"/>.

To unzip the xml from Archive i would recommend This SO post You should modify it to grab only the .xml file, and Documentation of ZipEntry is telling that it has a .getName() method. I will leave the xml-parsing research for you (that tutorial is not bad), and yes, its obviously possible.

EDIT: I found one library that could possibly do it - APK-Parser Github, but it was not tested on android. Some users are reporting some issues on android L

try(ApkParser apkParser = new ApkParser(new File(filePath))) {
     for (String permission: apkMeta.getUsesPermissions()) {
        Log.d("APK PERM",permission);
    }
}
Community
  • 1
  • 1
Toumash
  • 1,077
  • 11
  • 27