APKEditor Documentation

repository·master·Indexed 24 days ago

https://github.com/reandroid/apkeditor

A command-line Android APK resource editor using the ARSCLib library. It provides tools to decompile resources to JSON or XML, build APKs from decompiled files, merge split APKs into standalone files, refactor obfuscated resource names, protect/obfuscate resources, and inspect APK metadata and signatures.

Tokens
1.1K
Snippets
1
Records
11
Agent score
31%

What's inside APKEditor

  1. Build APKEditor from source

    master

    To build the executable fat JAR, use Gradle. Note that ARSCLib.jar is expected to be in APKEditor/libs/ARSCLib.jar or you must build it yourself and place it there.

    git clone https://github.com/REAndroid/APKEditor
    cd APKEditor
    ./gradlew fatJar

    The resulting executable JAR will be located in ./build/libs/APKEditor-x.x.x.jar.

    ./gradlew fatJar
  2. Refactor obfuscated resource names

    master

    Use the x (refactor) command to rename obfuscated resource entries back to readable names.

    Commonly used options:

    • -i: Input path to the APK.
    • -o: Output path for the refactored APK.
    • -public-xml: Path to a public.xml file containing resource IDs to apply to the resources.
  3. Build APK from decompiled files

    master

    Use the b (build) command to reconstruct an APK from a directory containing decompiled JSON, XML, or raw files.

    Commonly used options:

    • -i: Input path to the decompiled directory.
    • -o: Output path for the new APK.
    • -t: Build types (xml, json, raw, sig).
    • -extractNativeLibs: Controls how .so files are handled (manifest, none, true, false).
    • -dex-lib: Choose between internal or jf.
  4. Protect/Obfuscate APK resources

    master

    Use the p (protect) command to apply obfuscation techniques to APK resource files to protect them against decompile/modify tools.

    Commonly used options:

    • -i: Input path to the APK.
    • -o: Output path for the protected APK.
    • -dex-level: Protection level for dex files (0 to 5, where 0 is off). Default is 0.
    • -keep-type: Keep specific resource types (e.g., font). Can be used multiple times.
    • -confuse-zip: Confuses the zip structure (Note: may cause crashes if the app accesses APK files directly via getResourceAsStream()).
  5. Decompile APK resources to JSON or XML

    master

    Use the d (decode) command to decompile Android resources into human-readable formats. By default, it decompiles to JSON. To decompile to XML source code (for un-obfuscated APKs), use the -t xml option.

    Commonly used options:

    • -i: Input path to the APK.
    • -o: Output path for the decompiled files.
    • -t: Decode types (xml, json, raw, sig).
    • -framework: Path to framework files (e.g., framework-res.apk).
    • -dex-lib: Choose between internal (supports up to dex 042) or jf (supports 035 and below).
  6. Merge split APKs into a standalone APK

    master

    Use the m (merge) command to combine split APK files (from a directory or compressed formats like XAPK, APKM, APKS) into a single standalone APK.

    Commonly used options:

    • -i: Input path (directory or compressed file).
    • -o: Output path for the merged APK.
    • -validate-modules: Validates that split APKs have the same versionNumber as the base.apk.
  7. Get APK information and resource details

    master

    Use the info command to dump various metadata and resource information from an APK.

    Key Flags:

    • -v: Verbose mode.
    • -resources: Prints all resources.
    • -filter-type: When using -resources, limits output to specific types (e.g., drawable).
    • -package: Prints the package name.
    • -permissions: Prints declared permissions.
    • -signatures: Prints signature information.
    • -t [text|json|xml]: Specifies the output format.
  8. Use APKEditor via CLI

    master

    APKEditor is a command-line tool for editing Android APK resources. It provides several subcommands for different tasks such as decompiling, building, merging, refactoring, protecting, and inspecting APK files.

    To use APKEditor from a terminal, call the main method (typically via the compiled JAR). If you are integrating APKEditor into another Java application, use the execute(String[] args) method to avoid System.exit() calls.

  9. Execute APKEditor from a Java application

    master

    When embedding APKEditor into a Java application, use com.reandroid.apkeditor.Main.execute(String[] args) instead of main(String[] args). This prevents the tool from terminating the host JVM via System.exit().

    Return Codes:

    • 0: Executed successfully.
    • 1: An error occurred during execution.
    • 2: A non-executing command was called (e.g., --help or --version).