Ir al contenido

Más visitados

Visitados recientemente

navigation

apkanalyzer

The command-line version of APK Analyzer provides immediate insight into the composition of your APK after the build process completes, and allows you to compare differences between two APKs. By using APK Analyzer, you can reduce the time you spend debugging issues with DEX files and resources within your app and reduce the size of your APK.

apkanalyzer is included in the Android SDK Tools package and located at android_sdk/tools/bin/apkanalyzer. Alternatively, you can access the APK Analyzer tool within Android Studio as described in Analyze Your Build with APK Analyzer.

Syntax

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 one of the following.

The verb is what you want to know about the subject. The subjects, verbs, and their options are described in 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

Global Options

Option Description
--human-readable Prints sizes in human-readable format.

Commands

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

View APK file attributes Description
apk summary apk-file Prints the application ID, version code, and version name.

Example output:

com.myapp 5 1.1-beta
apk file-size apk-file Prints the total file size of the APK.
apk download-size apk-file Prints an estimate of the download size of the APK.
apk features [--not-required] apk-file Prints features used by the APK that trigger Play Store filtering . Add the --not-required option to include features marked as not required in the output.

Example output:

android.hardware.type.watch
android.hardware.microphone implied: requested android.permission.RECORD_AUDIO permission
apk compare [options] apk-file apk-file2 Compares the sizes of apk-file and apk-file2. You can include the following options:
  • --different-only: Print directories and files with differences.
  • --files-only: Do not print directory entries.
  • --patch-size: Show an estimate of the file-by-file patch instead of a raw difference.

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
...
View the APK file system Description
files list apk-file Lists all files in the APK.

Example output:

/
/classes2.dex
/classes.dex
/assets/
/assets/asset.data
/AndroidManifest.xml
/resources.arsc
/res/
...
files cat --file path apk-file Prints out the file contents. You must specify a path inside the APK using the --file path option, such as --file /AndroidManifest.xml
View information in the manifest Description
manifest print apk-file Prints the APK manifest in XML format.
manifest application-id apk-file Prints the application ID value.
manifest version-name apk-file Prints the version name value.
manifest version-code apk-file Prints the version code value.
manifest min-sdk apk-file Prints the minimum SDK version.
manifest target-sdk apk-file Prints the target SDK version.
manifest permissions apk-file Prints the list of permissions.
manifest debuggable apk-file Prints whether the app is debuggable.
Access DEX file information Description
dex list apk-file Prints a list of the DEX files in the APK.
dex references [--files path] [--files path2] apk-file 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.

Example output:

classes.dex 59598
classes2.dex 8042
dex packages [option1 option2 ...] apk-file 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.

Add the following options to refine the output:

  • --defined-only: Include only classes defined in the APK in the output.
  • --files: Specify the DEX file names to include. Default: all DEX files.
  • --proguard-folder file: Specify the Proguard output folder to search for mappings.
  • --proguard-mappings file: Specify the Proguard mappings file.
  • --proguard-seeds file: Specify the Proguard seeds file.
  • --proguard-usages file: Specify the Proguard usages file.
  • --show-removed: Show 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 class [--method method] 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. The format for the method decompile is name(params)returnType, for example, someMethod(Ljava/lang/String;I)V.
View resources stored in res/ and resources.arsc Description
resources packages Prints a list of the packages that are defined in the resources table.
resources configs --type type [--package package] apk-file Prints a list of configurations for the specified type. 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 config --name name --type type [--package package] apk-file Prints the value of the resource specified by config, name, 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 names --config config --type type [--package package] apk-file 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 path apk-file Prints the human-readable form of a binary XML file. Include the file option to specify the path to the file.

Utilizamos cookies para registrar tus preferencias de idioma y visualización de este sitio web.

Recibe novedades y consejos para desarrolladores de Android que te ayudarán a alcanzar el éxito en Google Play.

* Campos obligatorios

¡Ya está!

Seguir a Google Developers en WeChat

¿Quieres navegar por el sitio web en ?

Has solicitado que la página aparezca en , pero tu idioma preferido en este sitio web es el .

¿Quieres cambiar tu preferencia de idioma y navegar por este sitio web en ? Si prefieres dejarlo para más tarde, usa el menú de idioma que se encuentra en la parte inferior de cada página web.

Para esta clase se necesita un nivel de API o superior

La documentación está oculta porque el nivel de API que has seleccionado para ella es . Cambia el nivel de API de la documentación en el selector situado encima del menú de navegación de la izquierda.

Para obtener más información sobre cómo especificar el nivel de API que requiere tu aplicación, lee el artículo Supporting Different Platform Versions (Compatibilidad con diferentes versiones de la plataforma).

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)