Skip to content

ngr refactor

Updated on 30 November 2026

Gives readable names to the resources of an apk whose names are obfuscated and returns each resource file to the folder of its type. You use it to be able to read an apk whose resources are all called the same, or whose files are scattered over meaningless paths, before decoding it with ngr decode or looking at it with ngr info. The apk needs a resources.arsc. The output does not verify: it has to be signed again.

Usage

ngr refactor [options] <apk>

Inputs

Input What it is
<apk> An apk file with resources.arsc

Options

Option What it does Default
-o, --output <file> The apk to write <name>_refactored.apk next to the apk
-f, --force Overwrites the output if it already exists
--clean-meta Removes the signature entries and nulls the apk signing block
--fix-types Fixes misnamed resource types before renaming, so the new type reaches all the paths
-h, --help Shows the help

What it writes

The new apk, <name>_refactored.apk unless you say otherwise. The final line goes to stderr:

wrote app_refactored.apk

What changes, seen with ngr info --resources before and after in an apk whose resources are all called 0_resource_name_obfuscated:

  • Text resources take a name derived from their value. A string that says “first” is renamed first.
  • The others, and texts with nothing that gives a name, take the type and the identifier: layout_0x7f0d0000, string_0x7f120004.
  • Files move to the folder of their type, with the configuration qualifier as the folder suffix and the new name as the file name.

Before:

  type string id=18 entryCount=26
    resource 0x7f120003 string/0_resource_name_obfuscated
    resource 0x7f120004 string/0_resource_name_obfuscated

After:

  type string id=18 entryCount=26
    resource 0x7f120003 string/first
    resource 0x7f120004 string/string_0x7f120004

And the file paths, which go from loose names to folders by type:

res/WM.xml          ->  res/res/animator/animator_0x7f020000.xml
res/Sy.9.png        ->  res/res/drawable-nodpi/drawable_0x7f080006.9.png

A resource whose name was already readable keeps its name. In a normal apk, refactor still moves the resource files, from res/layout/row.xml to res/res/layout/row.xml.

Examples

Give readable names to an apk:

ngr refactor app.apk

Leave it in another file, without the signatures of the original:

ngr refactor --clean-meta -o app-readable.apk app.apk

Fix the misnamed types first:

ngr refactor --fix-types app.apk

Refactor and sign, which is what you need to install it:

ngr refactor app.apk
ngr sign --ks release.p12 --ks-pass env:KS_PASS app_refactored.apk

Exit codes

Code When
0 The apk was written. Also with a protected apk, which is left untouched and writes nothing
1 The apk does not exist or cannot be read, has no resources.arsc, or the output already exists and you did not pass -f
2 The options are wrong: <apk> is missing, there is an extra input or the option does not exist

Things to know

  • The output does not verify. It keeps the original signature over entries with a different name, and ngr verify ends with 3. Sign the result with ngr sign before installing it. With --clean-meta the signature entries disappear and verify says Missing META-INF/MANIFEST.MF; signing the resulting apk makes it verify.
  • The identifiers do not change. 0x7f120001 is still the same resource: only its name changes. That is why ngr resource app_refactored.apk 0x7f120001 keeps working.
  • An apk without resources.arsc is not refactored. refactor ends with 1:
ngr refactor: unable to refactor 'noarsc.apk': the input APK has no resources.arsc.

A .jar gives the same error.

  • A protected apk is left untouched. refactor writes its path and PROTECTED to stderr, writes no apk and ends with 0. The apk that ngr protect writes is in that case.
/Users/you/app_protected.apk
PROTECTED
  • It does not undo protect. An apk obfuscated with protect cannot be refactored.

See also