Commands
ngr has 19 commands in five areas. Each page says what the command does, which inputs and options it accepts,
what it writes and which code it ends with. The rules that all of them share are in
“How ngr works”.
Inspect an apk
They read and write nothing.
ngr identify: says what a file is and which commands accept it.ngr info: prints the package, versions, permissions, resources and files of an apk.ngr resource: shows entries of the resource table by identifier or by name.ngr xml: shows a compiled xml from inside the apk, such asAndroidManifest.xml.
Transform an apk
ngr decode: decodes an apk into a tree of resources, manifest and smali.ngr build: builds an apk from the tree thatdecodewrote.ngr merge: merges the split apks of a bundle (.xapk,.apkm,.apks) into a single one.ngr refactor: gives readable names to the resources of an apk and restores their paths.ngr protect: obfuscates the resource names, paths and binary manifest of an apk.
Align and sign
ngr align: aligns the uncompressed entries of a zip or an apk, or checks that they are aligned.ngr sign: signs an apk with the v1 to v4 schemes, with key rotation.ngr verify: checks the signatures of an apk.ngr rotate: creates or extends a signing certificate lineage.ngr lineage: reads a lineage and changes the capabilities of its signers.
Dex and smali
ngr disassemble: disassembles a dex into smali files, one per class.ngr assemble: assembles smali into a dex.ngr dump: prints an annotated hexadecimal dump of a dex.ngr list: lists the classes, strings, fields, methods or types of a dex.
Decompile
ngr decompile: decompiles a dex, an apk or an xapk to Java source code.
Which command do I need
| I want to... | Command |
|---|---|
| know what a file is | identify |
| see the package, version or permissions | info |
| read the manifest without unpacking anything | xml |
| change resources or code and repack | decode, build |
turn an .xapk into an installable apk |
merge, sign |
| sign an apk | sign |
| know whether an apk is properly signed and by whom | verify |
| change the signing key without losing updates | rotate, sign |
| read the code as Java | decompile |
| read or edit the code as smali | disassemble, assemble |
| look for a class, a method or a string | list |
How to read a command page
They all have the same sections, in this order:
- Usage: the shape of the command, as
ngr help <command>gives it. - Inputs and Options: what it accepts, with the defaults.
- What it writes: the files and what goes to stdout and stderr.
- Examples: commands you can copy, with their output.
- Exit codes: the ones that command can give.
- Things to know: what is worth knowing before you trust the result.
- See also: related commands and tasks.