The command-line version of APK Analyzer provides immediate insight into the
composition of your APK after the build process completes and lets you
compare differences between two APKs. Using APK Analyzer reduces the
time you spend debugging issues with DEX files and resources within your app and
reduces the size of your APK.

`apkanalyzer` is included in the
[Android SDK Command-Line Tools](https://developer.android.com/studio/command-line#tools-sdk) package at
<var translate="no">android_sdk</var>`/cmdline-tools/`<var translate="no">version</var>`/bin/apkanalyzer`.
Alternatively, you can access the APK Analyzer tool within
Android Studio as described in
[Analyze your build with APK Analyzer](https://developer.android.com/studio/debug/apk-analyzer).

## Syntax

The syntax for `apkanalyzer` is:  

```
apkanalyzer [global-options] subject verb [options] apk-file [apk-file2]
```

The `subject` is what you want to query and can be the entire APK
or a part of the APK. A subject can be any of the following:

- `apk`: Analyze APK file attributes such as application ID, version code, and version name.
- `files`: Analyze the files inside the APK file.
- `manifest`: Analyze the contents of the manifest inside the APK file.
- `dex`: Analyze the DEX files inside the APK file.
- `resources`: View text, image, and string resources.

The `verb` is what you want to know about the subject. The subjects,
verbs, and their options are described in the following section about [commands](https://developer.android.com/tools/apkanalyzer#commands).

Every command requires that you specify an APK file. Only the
`apk compare` command requires that you specify a second APK.

You can shorten every option as long as the option is unambiguous. For example,
the `--human-readable` global option can be shortened to
`-h`.

The following example analyzes the `apk` (subject)
to get its `file-size` (verb), and then prints the file size in a
human-readable format (`-h` option):  

```
apkanalyzer -h apk file-size myapk.apk
```

## Commands

The following command descriptions are organized by subject and list the
available verb and option combinations for each subject:

<br />

|                                                                                                     View APK file attributes                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `apk summary `<var translate="no">apk-file</var>                                                                                                                                                                                 | Prints the application ID, version code, and version name. <br /> Example output: ``` com.myapp 5 1.1-beta ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `apk file-size `<var translate="no">apk-file</var>                                                                                                                                                                               | Prints the total file size of the APK.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `apk download-size `<var translate="no">apk-file</var>                                                                                                                                                                           | Prints an estimate of the download size of the APK.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `apk features [--not-required] `<var translate="no">apk-file</var>                                                                                                                                                               | Prints features used by the APK that trigger [Play Store filtering](https://developer.android.com/google/play/filters#manifest-filters). Add the `--not-required` option to include features marked as not required in the output. <br /> Example output: ``` android.hardware.type.watch android.hardware.microphone implied: requested android.permission.RECORD_AUDIO permission ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `apk compare [`<var translate="no">options</var>`] `<var translate="no">apk-file</var>` `<var translate="no">apk-file2</var>                                                                                                     | Compares the sizes of <var translate="no">apk-file</var> and <var translate="no">apk-file2</var>. You can include the following options: - `--different-only`: Prints directories and files with differences. - `--files-only`: Does not print directory entries. - `--patch-size`: Shows an estimate of the file-by-file patch instead of a raw difference. <br /> Example output (old size / new size / size difference / path): ``` 39086736 48855615 9768879 / 10678448 11039232 360784 /classes.dex 18968956 18968956 0 /lib/ 110576 110100 -476 /AndroidManifest.xml ... ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` files list `<var translate="no">apk-file</var>                                                                                                                                                                                 | Lists all files in the APK. <br /> Example output: ``` / /classes2.dex /classes.dex /assets/ /assets/asset.data /AndroidManifest.xml /resources.arsc /res/ ... ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `files cat --file `<var translate="no">path</var>` `<var translate="no">apk-file</var>                                                                                                                                           | Prints out the file contents. You must specify a path inside the APK using the `--file `<var translate="no">path</var> option, such as `--file /AndroidManifest.xml`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `manifest print `<var translate="no">apk-file</var>                                                                                                                                                                              | Prints the APK manifest in XML format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `manifest application-id `<var translate="no">apk-file</var>                                                                                                                                                                     | Prints the application ID value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `manifest version-name `<var translate="no">apk-file</var>                                                                                                                                                                       | Prints the version name value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `manifest version-code `<var translate="no">apk-file</var>                                                                                                                                                                       | Prints the version code value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `manifest min-sdk `<var translate="no">apk-file</var>                                                                                                                                                                            | Prints the minimum SDK version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `manifest target-sdk `<var translate="no">apk-file</var>                                                                                                                                                                         | Prints the target SDK version.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `manifest permissions `<var translate="no">apk-file</var>                                                                                                                                                                        | Prints the list of permissions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `manifest debuggable `<var translate="no">apk-file</var>                                                                                                                                                                         | Prints whether the app is debuggable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `dex list `<var translate="no">apk-file</var>                                                                                                                                                                                    | Prints a list of the DEX files in the APK.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `dex references [--files `<var translate="no">path</var>`] [--files `<var translate="no">path2</var>`] `<var translate="no">apk-file</var>                                                                                       | Prints the number of method references in the specified DEX files. The default is all DEX files. Add the `--files` option to indicate specific files that you want to include. <br /> Example output: ``` classes.dex 59598 classes2.dex 8042 ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `dex packages [`<var translate="no">option1 option2 ...</var>`] `<var translate="no">apk-file</var>                                                                                                                              | Prints the class tree from DEX. In the output, `P`, `C`, `M`, and `F` indicate packages, classes, methods, and fields, respectively. And `x`, `k`, `r`, and `d` indicate removed, kept, referenced and defined nodes, respectively. <br /> Add the following options to refine the output: - `--defined-only`: Includes only classes defined in the APK in the output. - `--files`: Specifies the DEX file names to include. Default: all DEX files. - `--proguard-folder `<var translate="no">file</var>: Specifies the Proguard output folder to search for mappings. - `--proguard-mappings `<var translate="no">file</var>: Specifies the Proguard mappings file. - `--proguard-seeds `<var translate="no">file</var>: Specifies the Proguard seeds file. - `--proguard-usages `<var translate="no">file</var>: Specifies the Proguard usages file. - `--show-removed`: Shows classes and members that were removed by Proguard. Example output (type/state/defined methods/referenced methods /byte size/name): ``` P d 1 1 85 g P d 1 1 85 g.a C d 1 1 85 g.a.a M d 1 1 45 g.a.a java.lang.Object get() C r 0 1 40 byte[] M r 0 1 40 byte[] java.lang.Object clone() ``` |
| `dex code --class `<var translate="no">class</var>` [--method `<var translate="no">method</var>`]`                                                                                                                               | Prints the bytecode of a class or method in smali format. The class name is required and prints the fully qualified class name to decompile. Add the `--method` option to specify the method to decompile. <br /> The format for the method decompile is `name(params)returnType`, for example, `someMethod(Ljava/lang/String;I)V`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `resources packages`                                                                                                                                                                                                             | Prints a list of the packages that are defined in the resources table.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `resources configs --type `<var translate="no">type</var>` [--package `<var translate="no">package</var>`] `<var translate="no">apk-file</var>                                                                                   | Prints a list of configurations for the specified <var translate="no">type</var>. The `type` is a resource type such as `string`. Include the `--package` option if you want to specify the resource table package name, otherwise the first defined package will be used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `resources value --config `<var translate="no">config</var>` --name `<var translate="no">name</var>` --type `<var translate="no">type</var>` [--package `<var translate="no">package</var>`] `<var translate="no">apk-file</var> | Prints the value of the resource specified by <var translate="no">config</var>, <var translate="no">name</var>, and <var translate="no">type</var>. The `type` option is the type of the resource, such as `string`. <br /> Include the `--package` option if you want to specify the resource table package name, otherwise the first defined package will be used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `resources names --config `<var translate="no">config</var>` --type `<var translate="no">type</var>` [--package `<var translate="no">package</var>`] `<var translate="no">apk-file</var>                                         | Prints a list of resource names for a configuration and type. The `type` option is the type of the resource, such as `string`. Include the `--package` option if you want to specify the resource table package name, otherwise the first defined package will be used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `resources xml --file `<var translate="no">path</var>` `<var translate="no">apk-file</var>                                                                                                                                       | Prints the human-readable form of a binary XML file. Include the <var translate="no">file</var> option to specify the path to the file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

<br />