MCPcopy
hub / github.com/APKLab/APKLab / decompileAPK

Function decompileAPK

src/tools/jadx.ts:14–63  ·  view source on GitHub ↗
(
        apkFilePath: string,
        projectDir: string,
        jadxArgs: string[],
    )

Source from the content-addressed store, hash-verified

12 * @param jadxArgs array of additional args passed to **Jadx**.
13 */
14 export async function decompileAPK(
15 apkFilePath: string,
16 projectDir: string,
17 jadxArgs: string[],
18 ): Promise<void> {
19 if (!apkFilePath || !path.isAbsolute(apkFilePath)) {
20 vscode.window.showErrorMessage(
21 `APKLab: Invalid APK file path: ${apkFilePath}`,
22 );
23 return;
24 }
25
26 const extensionConfig =
27 vscode.workspace.getConfiguration(extensionConfigName);
28 const jadxDirPath = extensionConfig.get("jadxDirPath");
29
30 if (!jadxDirPath) {
31 vscode.window.showErrorMessage(
32 "APKLab: Jadx not configured. Please check your configuration.",
33 );
34 return;
35 }
36
37 const jadxExeName = `jadx${
38 process.platform.startsWith("win") ? ".bat" : ""
39 }`;
40 const jadxPath = path.join(String(jadxDirPath), "bin", jadxExeName);
41
42 if (!fs.existsSync(jadxPath)) {
43 vscode.window.showErrorMessage(
44 `APKLab: Jadx executable not found at: ${jadxPath}`,
45 );
46 return;
47 }
48
49 const apkDecompileDir = path.join(projectDir, JAVA_SOURCE_DIR);
50 const apkFileName = path.basename(apkFilePath);
51 const report = `Decompiling ${apkFileName} into ${apkDecompileDir}`;
52 let args = ["-r", "-q", "-ds", apkDecompileDir, apkFilePath];
53 if (jadxArgs && jadxArgs.length > 0) {
54 args = jadxArgs.concat(args);
55 }
56 await executeProcess({
57 name: "Decompiling",
58 report: report,
59 command: jadxPath,
60 args: args,
61 shouldExist: apkDecompileDir,
62 });
63 }
64}

Callers

nothing calls this directly

Calls 1

executeProcessFunction · 0.90

Tested by

no test coverage detected