Skip to content

[BUG] Issue: apktool reported as “not found” on Windows 11 / Claude Code even though it is installed and on PATH #7

@wlndysky

Description

@wlndysky

Issue: apktool reported as “not found” on Windows 11 / Claude Code even though it is installed and on PATH

Summary

On Windows 11, when running apktool-mcp-server from Claude Code (CLI) in stdio mode, MCP tools such as health_check() and decode_apk() fail with:

APKTool not found. Please ensure APKTool is installed and in PATH

This happens even though apktool is correctly installed, apktool.bat is on PATH, and apktool -version works in a normal cmd.exe session.

Environment

  • OS: Windows 11 (build 10.0.26200.7840)
  • Client: Claude Code v2.1.39 (stdio MCP)
  • apktool: 3.0.1
    • apktool.bat: E:\path\to\apktool\bin\apktool.bat
    • apktool.jar: E:\path\to\apktool\bin\apktool.jar
  • Java: Available on PATH (detected at C:\path\to\java.exe; JAVA_HOME not set)
  • uv: C:\Users\<user>\.cargo\bin\uv.exe

Steps to Reproduce

  1. Install apktool on Windows as apktool.bat + apktool.jar, and add the directory to PATH.
  2. Confirm in a normal terminal:
    where apktool
    apktool -version
    This works and prints 3.0.1.
  3. Start apktool-mcp-server via Claude Code MCP (stdio).
  4. Call the following MCP tools:
    • health_check()
    • decode_apk(apk_path="C:\\path\\to\\sample.apk", force=true)

Actual Result

  • health_check() returns:
    • apktool_available: false
    • apktool_error: "APKTool not found. Please ensure APKTool is installed and in PATH"
  • decode_apk() fails with the same error.

Expected Result

  • health_check() should return apktool_available: true and report the installed apktool version.
  • decode_apk() should successfully decode the APK.

Evidence / Debug Output

Inside the MCP server process:

  • shutil.which("apktool") resolves to an apktool.BAT on disk
  • PATH includes the directory containing apktool.bat
  • PATHEXT includes .BAT

But running:

subprocess.run(["apktool", "--version"], ...)

can still raise:

  • FileNotFoundError(2, 'The system cannot find the file specified')

Notes / Root Cause

This appears to be a Windows-specific issue when apktool is installed as a .bat wrapper: the executable is discoverable on PATH, but direct subprocess.run(["apktool", ...]) can fail in this host environment (Claude Code + stdio MCP), leading to a false “apktool not found” error.

Suggested Fix

Make Windows execution more robust for .bat-based apktool installs. Two possible approaches:

Option A: Support an explicit APKTOOL_PATH environment variable

  • Read a configurable command/path:
    APKTOOL_CMD = os.environ.get("APKTOOL_PATH", "apktool")
  • Use APKTOOL_CMD instead of hardcoding "apktool" in all calls (health check, decode, build, etc.).
  • On Windows, users can set:
    • APKTOOL_PATH=E:\path\to\apktool\bin\apktool.bat

Option B: Run apktool through cmd.exe on Windows

  • Replace direct calls with:
    ["cmd.exe", "/c", "apktool", "--version"]
    and similarly for decode/build commands.

Either option would prevent the false “apktool not found” error on Windows when apktool is distributed as a .bat wrapper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions