Skip to content

ngr decompile

Updated on 30 November 2026

Decompiles a dex, an apk or an xapk to Java source code: one .java for each top-level class, with its nested classes inside, in a package tree.

decompile does not hide what it cannot translate. Each method comes out in one of three categories, and each file starts with the count of its own:

  • natural: ordinary Java.
  • dispatcher: Java that javac accepts, but with a loop marked // nogar: dispatcher: where Java cannot structure the control flow.
  • smali: the code stays in smali, after a /* NOGAR ERROR: */ comment that gives the reason. javac rejects that class.

“The decompiler output” explains the categories, the reasons and the warnings.

Usage

ngr decompile [options] <file>

Inputs

Input What it is
<file> A dex, apk or xapk file

All the dex files of an apk are decompiled together, as a single batch.

Options

Output:

Option What it does Default
-o, --output <dir> The folder to write <name>_java/ next to the input
-f, --force Writes into the folder even if it exists, and overwrites the --report file. The folder is not emptied first
-j, --jobs <n> Number of threads. The output does not depend on it One per core
--report <file> Also writes a JSON report: the options, the counts, the warnings of each class and the category of each method, with its reasons and regions when it is not natural
--stubs Also writes nogar-stubs/ in the output: minimal declarations of the classes the app uses that neither it nor the platform declares, so that javac can compile the output. The stubs are not decompiled code and are not counted

Which Java is written:

Option What it does Default
--java-version <7|8|11|17|21|25> The Java language level of the output. With 7, interface methods that have a body come out as smali, and below 11, so do their private methods. With 25, a constructor can run statements before its call to super(...) or this(...); below 25 they are moved after the call or, if that is not possible, the constructor comes out as smali 8
--unstructured <dispatcher|smali> What to write for the part of a method whose control flow Java cannot structure: a dispatcher loop, or that part as smali dispatcher
--line-numbers Writes /* line N */ before each statement whose code has a line number in the debug information, to match stack traces with the output. Cannot be combined with --debug-info ignore

Which platform it reads against:

Option What it does Default
--android-api <level> The Android API level the app is read against, which decides what the platform declares The manifest's compileSdkVersion; if there is none, its targetSdkVersion; if neither, 36
--android-jar <file> Reads the platform from this android.jar instead of the Android API model that nogar ships with. Cannot be combined with --android-api

Names:

Option What it does Default
--debug-info <use|ignore> Whether parameters and local variables take their name from the dex debug information, when they are valid Java names that fit the code. ignore names them as if the dex had none and does not read line numbers use
--kotlin-metadata <use|ignore> Whether the parameters of Kotlin methods take their name from their kotlin.Metadata annotation, or from the parameter checks that the Kotlin compiler inserts, when the debug information has no names use
--mappings <file> Reads this R8 or ProGuard mapping.txt and writes the classes and members with the names it gives, to the extent that its names match the classes of the input. A mapping that matches no class is not applied, and a warning is given
--deobf Writes with invented names the classes, methods, fields and package segments whose name has two characters or fewer, or is not a Java name. It takes them from what the dex shows: source file names, field types, or the element class and the original name. Each one gives its original name in a /* renamed from */ comment, and --report lists them

Which classes:

Option What it does Default
--classes <classes> Decompiles only these classes: type descriptors separated by commas (La/b;,Lc/d;). Can be repeated
--packages <prefixes> Writes only the files of the classes in these packages or the ones below them: package names with dots, separated by commas. Can be repeated
--exclude-packages <prefixes> Does not write the files of the classes in these packages or the ones below them. It wins over --packages and --classes. Can be repeated
-h, --help Shows the help

What it writes

A folder with the package tree:

app_java/
  com/example/app/MainActivity.java
  com/example/app/Counter.java
  ...

Each file starts with the count of its methods by category:

/* nogar: 7 methods: 7 natural, 0 dispatcher, 0 smali */
package com.example.app;

public class Counter {
    public static final int LIMIT = 100;
    private int value;

    public void add(int i) {
        if (i < 0) {
            throw new IllegalArgumentException("negative: " + i);
        }
        this.value = Math.min(100, this.value + i);
    }
    ...
}

Stderr gets, in this order:

  1. one WARN: line for each kind of class warning, with how many classes have it and what it means;
  2. a WARN: line with the methods and fields written as smali, if there are any;
  3. the summary: classes, methods by category and files written;
  4. the wrote line, with what was written and where.
WARN: 1 class(es): no constructor: the dex declares no constructor; javac adds a default one
WARN: 2 method(s) were written as smali; see the NOGAR ERROR comments
ngr decompile: 25 classes, 49 methods: 46 natural, 1 dispatcher, 2 smali; 25 files written
wrote 25 file(s) to classes_java

With --report, the JSON file has the same thing class by class and method by method (“The decompiler output”).

Examples

Decompile a whole apk:

ngr decompile app.apk

Decompile only the app's packages and leave a library out:

ngr decompile --packages com.example --exclude-packages com.example.thirdparty app.apk

Decompile one class:

ngr decompile --classes 'Lcom/example/app/MainActivity;' app.apk

Decompile an obfuscated apk with its mapping.txt, or without it giving readable names to the short ones:

ngr decompile --mappings mapping.txt app.apk
ngr decompile --deobf app.apk

Get output that javac can compile, with Java 17, stubs and a report:

ngr decompile --java-version 17 --stubs --report report.json app.apk

Exit codes

Code When
0 Everything was written as Java, natural or dispatcher
1 The input or the --android-jar cannot be read, the folder exists and you did not pass -f, or some file or the --report could not be written. The other files and the report are written anyway
2 The options are wrong
3 Some method, field or region was written as smali: because Java cannot express it, because --unstructured smali asked for it, or because its translation is not supported yet or failed

With code 3 the folder is complete. What it says is that not everything is Java.

Things to know

  • --classes, --packages and --exclude-packages filter what is written, not what is analyzed. Names and nesting are decided for the whole input, so each file is the same as in a full run. A --classes descriptor that belongs to no class gives a warning.
  • Some declarations change name. javac would reject their names from the dex: names that differ only in case, that clash with others or that are in the default package. Each one gives its original name in a /* renamed from */ comment, and --report lists all the changes. If you recompile the output, reflection, JNI, serialization, the manifest and the resources will see the new names, not the ones from the dex.
  • Where Java cannot keep a modifier or a member of the dex, the output changes it in a declared way, and --report notes it (“Declared deviations”).
  • A nested class whose file belongs to another package is written on its own in its package, without the file that contains it.
  • -f does not empty the folder. If you decompile twice into the same one with different filters, the files from both runs remain.
  • The output is Java. A class written in Kotlin comes out as the Java equivalent of its bytecode.
  • The dex must be of a version that ngr reads: 035, 037, 038, 039 or 040.

See also