Apk modding workflow

From bolone-sengkuni/hermes-brutal-mod · View interactive version

Apk modding workflow is an AI agent skill from the GitHub repository bolone-sengkuni/hermes-brutal-mod. Use for Android APK decompile, modify, and proper signing.

How to use this skill

Skill file

APK Modding Workflow

Proper workflow for decompiling, modifying, and repackaging Android APK files with modern signature schemes that work on Android 7-15.

When to Use This Skill

Trigger when the user:

Core Problem

Manual Python zipfile repacking FAILS. It doesn't preserve APK alignment and binary XML structure, causing "Application not installed because package appears invalid" errors on Android 7+.

jarsigner alone is INSUFFICIENT for Android 7+. It only signs with v1 scheme (JAR signature). Modern Android requires APK Signature Scheme v2/v3.

The Working Workflow

Step 1: Install Tools

# Download apktool (proper decompile/recompile)
cd ~/tools
curl -L -o apktool.jar "https://github.com/iBotPeaches/Apktool/releases/download/v2.10.0/apktool_2.10.0.jar"

# Download uber-apk-signer (zipalign + v1/v2/v3/v4 signing in one step)
curl -L -o uber-apk-signer.jar "https://github.com/patrickfav/uber-apk-signer/releases/download/v1.3.0/uber-apk-signer-1.3.0.jar"

Step 2: Decompile APK

java -jar apktool.jar d original.apk -o app-decompiled -f

What this does:

Step 3: Modify

Common modifications:

A. Make Debuggable (for Frida/runtime hooking):

Edit app-decompiled/AndroidManifest.xml:

<application android:debuggable="true" ...>

B. Change App Label:

<application android:label="App Name PRO" ...>

C. Disable SSL Pinning (if present):

Search smali for TrustManager, SSLContext, HostnameVerifier and patch validation methods to always return true.

D. Patch Premium Checks (Java/Kotlin apps only):

Search smali for isPremium, isSubscribed, hasLicense:

cd app-decompiled/smali
grep -r "isPremium" .
grep -r "license" .

Modify methods to return const/4 v0, 0x1 (true).

E. Remove Ads:

Delete ad library directories from smali/ (e.g., smali/com/google/android/gms/ads/).

Step 4: Recompile

java -jar apktool.jar b app-decompiled -o app-modded-unsigned.apk

Step 5: Sign with Modern Signature Schemes

java -jar uber-apk-signer.jar --apks app-modded-unsigned.apk --allowResign

Output: app-modded-aligned-debugSigned.apk

What uber-apk-signer does:

Step 6: Install

adb install app-modded-aligned-debugSigned.apk

Or send to user via Telegram:

MEDIA:/path/to/app-modded-aligned-debugSigned.apk

Alternative: Custom Keystore

If you need a custom keystore (not debug):

# Generate keystore (one time)
keytool -genkey -v -keystore my.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 10000 -storepass password123 -keypass password123 -dname "CN=YourName, OU=Mod, O=Org, L=City, ST=State, C=ID"

# Sign with custom keystore
java -jar uber-apk-signer.jar --apks app-modded-unsigned.apk --ks my.keystore --ksAlias mykey --ksPass password123 --ksKeyPass password123

Flutter Apps: Static Patching is Limited

How to identify Flutter:

What you CAN modify:

What you CANNOT modify via static patching:

For Flutter premium unlock:

  1. Make debuggable (Step 3A above)
  2. Recompile & sign (Steps 4-5)
  3. Runtime bypass with Frida:
// Frida script example (bypass isPremium check)
Java.perform(function() {
    var SharedPreferences = Java.use("android.content.SharedPreferences");
    SharedPreferences.getBoolean.overload('java.lang.String', 'boolean').implementation = function(key, defValue) {
        if (key.includes("premium") || key.includes("pro") || key.includes("license")) {
            console.log("[+] Bypassing premium check: " + key + " -> true");
            return true;
        }
        return this.getBoolean(key, defValue);
    };
});

Run: frida -U -f com.package.name -l bypass.js --no-pause

  1. Or use Lucky Patcher (easier for non-root):

Common Errors & Fixes

Error: "Application not installed because package appears invalid"

Cause 1: Manual Python zipfile repack (corrupt structure)

Fix: Use apktool for decompile/recompile (Steps 2, 4)

Cause 2: Signed with jarsigner only (missing v2/v3 signatures)

Fix: Use uber-apk-signer (Step 5)

Cause 3: APK not zipaligned

Fix: uber-apk-signer auto-handles this

Error: "INSTALL_PARSE_FAILED_NO_CERTIFICATES"

Cause: APK unsigned or signature corrupted

Fix: Re-sign with uber-apk-signer (Step 5)

Error: "INSTALL_FAILED_UPDATE_INCOMPATIBLE"

Cause: Trying to install over existing app with different signature

Fix: Uninstall original app first, then install modded APK

Apktool Error: "brut.common.BrutException: could not exec"

Cause: aapt/aapt2 binary missing or not executable

Fix:

# Linux/Mac
chmod +x ~/.local/share/apktool/framework/aapt*

# Windows: download aapt.exe separately and place in apktool dir

Signature Schemes Explained

| Scheme | Android Version | Tool Support |

|:-------|:----------------|:-------------|

| v1 (JAR) | All versions | jarsigner, apksigner, uber-apk-signer |

| v2 (APK) | 7.0+ (API 24+) | apksigner, uber-apk-signer |

| v3 (APK) | 9.0+ (API 28+) | apksigner, uber-apk-signer |

| v4 (Streaming) | 11.0+ (API 30+) | uber-apk-signer |

Modern best practice: Sign with v1+v2+v3 for maximum compatibility (Android 4.4 - 15). uber-apk-signer does this automatically.

Why jarsigner fails: It only signs v1. Android 7+ verifies v2/v3 first if present; if absent but targeting API 24+, install fails.

Tool Comparison

| Tool | Pros | Cons |

|:-----|:-----|:-----|

| apktool | Proper decompile, editable XML/smali, preserves structure | Requires Java, slower than zipfile |

| uber-apk-signer | One-step zipalign+sign, all schemes, auto-verify | Requires Java |

| jarsigner | Built-in to JDK | v1 only, fails on Android 7+ |

| Python zipfile | Fast, no deps | Corrupts APK structure, DO NOT USE |

| Lucky Patcher | User-friendly GUI, works on-device | Requires Android device, not scriptable |

Quick Reference

# Full workflow
java -jar apktool.jar d original.apk -o app-decompiled -f
# [modify app-decompiled/AndroidManifest.xml or smali/]
java -jar apktool.jar b app-decompiled -o app-unsigned.apk
java -jar uber-apk-signer.jar --apks app-unsigned.apk --allowResign
# Result: app-aligned-debugSigned.apk

When This Workflow Fails

1. Obfuscated code — ProGuard/R8 makes smali unreadable. Need to:

2. Anti-tamper checks — App detects modification at runtime:

Bypass:

3. Server-side validation — App checks license/premium status via API:

Source & Documentation

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.