agentleFS
yaron4uyaron4u/pi-android-re/skills/android-static-analysis/SKILL.md

android-static-analysis

Skill12 starsChanged 7 months agoApache-2.0View on GitHub

Decompile Android APK, XAPK, JAR, and AAR files using jadx or Fernflower/Vineflower. Reverse engineer Android apps, extract HTTP API endpoints (Retrofit, OkHttp, Volley), trace call flows from UI to network layer, analyze obfuscated code. Use when the user wants to decompile, analyze, or reverse engineer Android packages, find API endpoints, follow call flows, or perform static analysis on Android applications.

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. About 0 are common, 7 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the dependency checker:

    line 14
  2. Very specific:

    If anything is missing, see references/setup-guide.md in this skill directory.

    line 20
  3. Distinctive:

    Before selecting commands, load the static canonical routing references.

    line 26
  4. Very specific:

    Read references/script-metadata.manifest.json and select the preferred canonical profile.

    line 43
  5. Distinctive:

    Use fallback profiles only if the preferred path fails or misses target output.

    line 44
  6. Distinctive:

    Before doing anything, ensure the environment isn't garbage.

    line 55
  7. Distinctive:

    If required dependencies are missing (Exit Code 1):

    line 61
  8. Very specific:

    If apk-install-dep exits with Code 2 (requires manual sudo), print the exact instructions for the user and halt.

    line 67
  9. Very specific:

    After any installations, re-run apk-check-deps to confirm.

    line 71
  10. Very specific:

    When using --engine both, outputs go into <output>/jadx/ and <output>/fernflower/ with a comparison summary.

    line 101
  11. Very specific:

    Manifest: Read <output>/resources/AndroidManifest.xml (or <output>/base/resources/AndroidManifest.xml for bundles).

    line 107
  12. Very specific:

    Run ls to map top-level packages

    line 113
  13. Very specific:

    Look for packages named api, network, data, repository, service, retrofit, http

    line 115
  14. Very specific:

    Start at Activity.onCreate() or Fragment.onViewCreated().

    line 125
  15. Very specific:

    When the code looks like a.b.c(), do not give up.

    line 171
  16. Very specific:

    If you read a Java file decompiled by Jadx and see /* JADX WARNING: ...

    line 179
  17. Distinctive:

    Headless Only: Do not attempt to open the Ghidra GUI.

    line 183
  18. Distinctive:

    USE the browser: if you are unsure about how a decompiler flag works or what a specific Android API does.

    line 196
  19. Very specific:

    If rg is available, prefer it over grep.

    line 197

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Android Static Analysis

Decompile Android APK, XAPK, JAR, and AAR files using jadx and Fernflower/Vineflower, trace call flows through application code and libraries, and produce structured documentation of extracted APIs.

Prerequisites

This skill requires Java JDK 17+ and jadx. Fernflower/Vineflower and dex2jar are optional but recommended.

Run the dependency checker:

bash ~/.pi/agent/skills/android-static-analysis/scripts/check-deps.sh

If anything is missing, see references/setup-guide.md in this skill directory.


REQUIRED REFERENCE LOADING

Before selecting commands, load the static canonical routing references. Do not guess flags or randomly switch engines.

Reference Files

FileRead When
references/canonical-scripts.mdSelecting canonical script/profile IDs before execution
references/script-metadata.manifest.jsonDeterministic routing: intent/file-type -> preferred/fallback profile IDs
references/setup-guide.mdInstalling or repairing missing dependencies
references/jadx-usage.mdJadx flags, deobf strategy, and APK workflows
references/fernflower-usage.mdFernflower/Vineflower behavior and dex2jar flow
references/api-extraction-patterns.mdRetrofit/OkHttp/Volley/WebView endpoint extraction patterns
references/call-flow-analysis.mdUI->ViewModel/Presenter->Repository->Network tracing

Mandatory Pre-Routing Workflow

  1. Read references/canonical-scripts.md first.
  2. Read references/script-metadata.manifest.json and select the preferred canonical profile.
  3. Use fallback profiles only if the preferred path fails or misses target output.
  4. Then execute the 5-phase workflow below.

THE 5-PHASE REVERSE ENGINEERING WORKFLOW

You are equipped with global CLI tools (apk-*). Execute this exact 5-phase workflow when handed an Android application. Do not deviate.

PHASE 1: Verify Dependencies

Before doing anything, ensure the environment isn't garbage.

apk-check-deps

If required dependencies are missing (Exit Code 1):

apk-install-dep <dep_name>

If apk-install-dep exits with Code 2 (requires manual sudo), print the exact instructions for the user and halt.

Optional dependencies (vineflower, dex2jar) are highly recommended. Ask the user if they want them installed.

After any installations, re-run apk-check-deps to confirm. Do not proceed until all required dependencies pass.

PHASE 2: Decompile Target

apk-decompile [OPTIONS] <file>

Engine Selection Strategy (CRITICAL):

SituationEngine
First pass on any APK/XAPK--engine jadx (fastest, handles resources)
JAR/AAR library analysis--engine fernflower (better Java output)
Jadx output has warnings/broken code--engine both (compare per class)
Complex lambdas, generics, streams--engine fernflower
Quick overview of a large APKjadx --no-res

Flags:

  • -o <dir>: Custom output directory (default: <filename>-decompiled)
  • --deobf: Enable Jadx deobfuscation (mandatory for obfuscated apps)
  • --no-res: Skip resources, decompile code only (faster for massive APKs)
  • --engine ENGINE: jadx (default), fernflower, or both

XAPK & Split Bundles: The script automatically handles XAPKs and bundled splits. If the app is a bundle, the script extracts it and decompiles the base.apk into <output>/base/sources/. Look for the base/ subdirectory before saying the app is empty!

When using --engine both, outputs go into <output>/jadx/ and <output>/fernflower/ with a comparison summary.

PHASE 3: Analyze Structure

Navigate the output using bash and grep, NEVER by reading the root directory.

  1. Manifest: Read <output>/resources/AndroidManifest.xml (or <output>/base/resources/AndroidManifest.xml for bundles).
  • Identify the main launcher Activity
  • List all Activities, Services, BroadcastReceivers, ContentProviders
  • Note permissions (especially INTERNET, ACCESS_NETWORK_STATE)
  • Find the application class (android:name on <application>)
  1. Survey the package structure under <output>/sources/:
  • Run ls to map top-level packages
  • Distinguish app code from third-party libraries
  • Look for packages named api, network, data, repository, service, retrofit, http
  1. Identify the architecture pattern:
  • MVP: look for Presenter classes
  • MVVM: look for ViewModel classes and LiveData/StateFlow
  • Clean Architecture: look for domain, data, presentation packages

PHASE 4: Trace Call Flows

Trace execution from the UI down to the network layer. Follow the exact Android Lifecycle:

  1. Start at Activity.onCreate() or Fragment.onViewCreated().
  2. Grep for Click Handlers: rg 'setOnClickListener|onClick' <output>/sources/
  3. Trace to the ViewModel/Presenter: rg 'ViewModel|Presenter' <output>/sources/
  4. Trace to the Repository: rg 'Repository' <output>/sources/
  5. Map Dependency Injection (Dagger/Hilt): rg '@Provides|@Binds|@Inject|@Module' <output>/sources/

See references/call-flow-analysis.md for detailed techniques.

PHASE 5: Extract and Document APIs

apk-find-apis <output>/sources/ [OPTIONS]

Targeted searches:

apk-find-apis <output>/sources/ --retrofit
apk-find-apis <output>/sources/ --urls
apk-find-apis <output>/sources/ --auth

Then read the surrounding source code to extract full endpoint details.

MANDATORY DOCUMENTATION FORMAT:

For every API endpoint discovered, document it exactly like this:

### `METHOD /path`
- **Source**: `com.example.api.ApiService` (ApiService.java:42)
- **Base URL**: `https://api.example.com/v1` (Found in NetworkModule.java)
- **Path params**: `id` (String)
- **Query params**: `page` (int), `limit` (int)
- **Headers**: `Authorization: Bearer <token>`
- **Request body**: `{ "email": "string", "password": "string" }`
- **Response**: `ApiResponse<User>`
- **Called from**: `LoginActivity -> LoginViewModel -> UserRepository -> ApiService`

ADVANCED TECHNIQUES (STRICT ENFORCEMENT)

Handling Obfuscation (ProGuard / R8)

When the code looks like a.b.c(), do not give up.

  • Strings are anchors: URLs, error messages, and JSON keys are never obfuscated. Grep for "https://" or "auth/login".
  • Frameworks are anchors: Activity, Fragment, and Intent keep their names.
  • Annotations are anchors: Retrofit @GET and @POST are never obfuscated. If c.a.b has @POST("login"), it is the Retrofit interface. Trace who calls it.

Jadx vs Vineflower (Fernflower)

If you read a Java file decompiled by Jadx and see /* JADX WARNING: ... */ or // Error: ... inside a method body, stop reading. Jadx failed to build the AST. Re-run with --engine fernflower and read the Vineflower output for that specific file instead.

Native Library Analysis (Ghidra)

  • Headless Only: Do not attempt to open the Ghidra GUI.
  • Headless Execution:
    /path/to/ghidra/support/analyzeHeadless /tmp/ghidra_proj target_proj -process libtarget.so -postScript your_script.py

TOOLS & ACCURACY

Do not guess. Do not hallucinate.

  1. USE Context7 MCP to verify library APIs and tool signatures before writing commands.
  2. USE the browser if you are unsure about how a decompiler flag works or what a specific Android API does.
  3. If rg is available, prefer it over grep. It is faster.

COMMON PITFALLS (REJECT THESE ON SIGHT)

PitfallWhy It's WrongFix
Reading classes.dexCompiled Dalvik bytecode. Unreadable.Run apk-decompile first.
read output/sources/Blows up the context window.rg "keyword" output/sources/ first.
Giving up on a.b.cObfuscation is a feature, not an excuse.Grep for strings/annotations to find anchors.
Staring at Jadx // ErrorJadx failed to decompile the method block.Re-run with --engine fernflower.
Missing the Base URLRetrofit interfaces don't contain the domain.Grep for Retrofit.Builder().baseUrl() or Application onCreate.
"App has no sources"It's an XAPK/Split wrapper.Look inside output/base/sources/.

OUTPUT

At the end of the workflow, deliver:

  1. Decompiled source in the output directory
  2. Architecture summary -- app structure, main packages, pattern used
  3. API documentation -- all discovered endpoints in the format above
  4. Call flow map -- key paths from UI to network (especially authentication and main features)

References

  • references/canonical-scripts.md -- Canonical script IDs and profile presets
  • references/script-metadata.manifest.json -- Deterministic routing metadata (preferred/fallback IDs)
  • references/setup-guide.md -- Installing Java, jadx, Fernflower/Vineflower, dex2jar
  • references/jadx-usage.md -- jadx CLI options and workflows
  • references/fernflower-usage.md -- Fernflower/Vineflower CLI options, APK workflow
  • references/api-extraction-patterns.md -- Library-specific search patterns and documentation template
  • references/call-flow-analysis.md -- Techniques for tracing call flows in decompiled code

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.