Skip to content

ngr disassemble

Updated on 30 November 2026

Disassembles a dex into a tree of .smali files, one per class. From an apk or an xapk it reads all the dex files and writes one folder for each. You use it when you only want an app's code as smali, without decoding the resources. ngr assemble does the reverse.

Usage

ngr disassemble [options] <file>

Inputs

Input What it is
<file> A dex, an apk or an xapk, or a dex inside an apk (app.apk/classes2.dex)

Options

Option What it does Default
-o, --output <dir> The folder to write <name>_smali/ next to the input
-f, --force Writes into the folder even if it exists. Unlike decode, it does not empty it first
-j, --jobs <n> Number of threads. The output does not depend on it One per core
--use-locals Writes .locals (the registers that are not parameters) instead of .registers
--no-debug-info Leaves out the debug information (.line, .local, .param...)
--no-accessor-comments Leaves out the comments on calls to synthetic accessors
--no-parameter-registers Names every register vNN, without the pNN form for parameters
--code-offsets Puts a comment with its position in the code before each instruction
--implicit-references Names the members of the class itself without the class name
--sequential-labels Numbers the labels of each kind in order, instead of by address
--classes <classes> Disassembles only these classes: type descriptors separated by commas (La/b;,Lc/d;). Can be repeated All
--resolve-resources <prefix=public.xml> Comments each resource number with its name, read from a public.xml. prefix is the name of the R class
-h, --help Shows the help

What it writes

A folder with one .smali per class, in subfolders that follow the package name. With a bare dex:

classes_smali/
  com/example/app/Counter.smali
  com/example/app/MainActivity.smali
  ...

With an apk or an xapk there is one folder per dex, classes/, classes2/..., each with its packages:

app_smali/
  classes/com/example/app/Counter.smali
  classes2/com/example/extra/Helper.smali

With a dex inside an apk (app.apk/classes2.dex), the packages hang directly from the output folder.

The final line goes to stderr:

wrote 43 file(s) to app_smali

Examples

Disassemble a dex:

ngr disassemble classes.dex

Disassemble all the dex files of an apk, into another folder:

ngr disassemble -o code app.apk

Disassemble only the second dex of an apk:

ngr disassemble app.apk/classes2.dex

Disassemble only two classes, and do it again over the same folder:

ngr disassemble -f --classes 'Lcom/example/app/Counter;,Lcom/example/app/Mode;' classes.dex

Smali that is shorter to read, without the debug information and with the labels numbered in order:

ngr disassemble --no-debug-info --sequential-labels classes.dex

Comment each resource number with its name. ngr decode writes the public.xml in resources/package_1/res/values/:

ngr disassemble --resolve-resources com.example.app=app/resources/package_1/res/values/public.xml classes.dex

How each option changes the smali

All the snippets come from the same class. With no options, a method looks like this:

.method public static fib(I)J
    .registers 4

    .line 14
    sget-object v0, Lcom/example/app/Counter;->TABLE:[J

    array-length v1, v0

    if-ge p0, v1, :cond_8
  • --use-locals changes the registers directive: .registers 4 becomes .locals 3, because fib has one parameter.
  • --no-debug-info removes the .line 14 lines and the other debug directives.
  • --no-parameter-registers names the parameter as a normal register: if-ge p0, v1, :cond_8 becomes if-ge v3, v1, :cond_8.
  • --code-offsets puts a comment with its position, in code units, before each instruction:
    #@0
    .line 3
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    #@3
    return-void
  • --implicit-references removes the class name from the members of the class itself: sget-object v0, Lcom/example/app/Counter;->TABLE:[J becomes sget-object v0, TABLE:[J.
  • --sequential-labels numbers the labels of each kind from 0 instead of by address: :cond_8 becomes :cond_0, and :try_start_3, :try_end_9 and :catchall_b become :try_start_0, :try_end_0 and :catchall_0.
  • --no-accessor-comments removes the comment that ngr puts before the call to a synthetic accessor, for example:
    # getter for: Lcom/example/app/Registry;->entries:Ljava/util/Map;
    invoke-static {v0}, Lcom/example/app/Registry;->access$000(Lcom/example/app/Registry;)Ljava/util/Map;
  • --resolve-resources adds its name at the end of each resource number. With the prefix com.example.app:
    const p1, 0x7f120009    # com.example.app.string.greeting
    const/high16 p1, 0x7f0d0000    # com.example.app.layout.activity_main

The prefix is copied as is into the comment: with R you get # R.string.greeting.

Exit codes

Code When
0 The smali was written. Also if --classes names no class that exists
1 The input or the public.xml does not exist or cannot be read, or the folder already exists and you did not pass -f
2 The options are wrong: <file> is missing, --jobs is less than 1, or --resolve-resources is not of the form <prefix>=<file>

Things to know

  • -f does not empty the folder. It writes over the files that match and leaves the others, including any you put there. ngr decode -f does empty it.
  • A class name that does not exist is not an error. With --classes 'Lnope/X;' the command ends with 0 without writing anything and without saying anything: no folder and no wrote line.
  • Dex files with hidden api restrictions lose those marks. ngr warns on stderr, and the smali does not include them:
WARN: 'hiddenapi.dex' carries hidden api restrictions (whitelist, greylist, blacklist...) that nogar does not read; the smali leaves them out
  • --jobs does not change the result, only how long it takes.
  • The smali it writes is what ngr assemble reads. The dex that comes out of assembling it is not identical to the original.

See also