{"record":{"id":"762075a3be01f1db","repo":"iBotPeaches/Apktool","slug":"could-not-baksmali-file-dexname","errorCode":null,"errorMessage":"Could not baksmali file: {dexName}","messagePattern":"Could not baksmali file: (.+?)","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/smali/SmaliDecoder.java","lineNumber":119,"sourceCode":"\n                if (dexFile.supportsOptimizedOpcodes()) {\n                    throw new AndrolibException(\"Cannot disassemble an odex file without deodexing it: \" + dexName);\n                }\n\n                String dirName = \"smali\";\n                if (dexNum > 1 || !dexName.equals(\"classes.dex\")) {\n                    dirName += \"_\" + dexName.substring(0, dexName.lastIndexOf('.')).replace('/', '@');\n                    if (dexNum > 1) {\n                        dirName += dexNum;\n                    }\n                }\n\n                decodeFile(dexFile, new File(outDir, dirName));\n            }\n\n            mDexFiles.add(dexName);\n        } catch (IOException ex) {\n            throw new AndrolibException(\"Could not baksmali file: \" + dexName, ex);\n        }\n    }\n\n    private void decodeFile(DexBackedDexFile dexFile, File smaliDir) {\n        int jobs = Math.min(Runtime.getRuntime().availableProcessors(), 6);\n\n        BaksmaliOptions options = new BaksmaliOptions();\n        options.parameterRegisters = true;\n        options.localsDirective = true;\n        options.sequentialLabels = true;\n        options.debugInfo = mDebugMode;\n        options.codeOffsets = false;\n        options.accessorComments = false;\n        options.allowOdex = false;\n        options.deodex = false;\n        options.implicitReferences = false;\n        options.normalizeVirtualMethods = false;\n        options.registerInfo = 0;","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/smali/SmaliDecoder.java#L101-L137","documentation":"SmaliDecoder.decode wrapped an IOException thrown while reading dex entries or writing the baksmali output folders. The message names the dex being decoded and preserves the underlying IOException as the cause.","triggerScenarios":"Any IOException from the container streams (truncated dex entry, CRC failure mid-read) or from writing smali files to outDir (disk full, permission denied, deleted parent directory) during the decode loop.","commonSituations":"Output directory on a full or read-only mount; APK with a corrupt dex entry that only fails when its bytes are read; long decode runs interrupted by disk/quota limits in CI.","solutions":["Inspect the cause: a write-side exception points at outDir (permissions/space), a read-side one at the APK","Verify dex integrity: `unzip -t app.apk` and confirm CRCs pass","Free space or fix permissions on the output directory, then rerun","If the dex itself is damaged, re-obtain the APK; do not retry unchanged on a known-corrupt input"],"exampleFix":"# before\napktool d app.apk -o /read-only/out   # Could not baksmali file: classes.dex\n\n# after\nmkdir -p /tmp/work/out && chmod u+w /tmp/work/out\napktool d app.apk -o /tmp/work/out","handlingStrategy":"try-catch","validationCode":"// Check writable output and readable input before decode\nif (!outDir.isDirectory() || !outDir.canWrite()) throw new IOException(\"outDir not writable: \" + outDir);\nlong free = outDir.getUsableSpace();\nif (free < apkFile.length() * 4) System.err.println(\"Warning: low disk space for smali output\");","typeGuard":null,"tryCatchPattern":"try {\n    decoder.decode(dexName, outDir);\n} catch (AndrolibException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not baksmali file\")) {\n        IOException cause = (IOException) e.getCause();\n        // read side: corrupt dex -> re-obtain APK; write side: fix outDir, then retry ONCE\n    } else { throw e; }\n}","preventionTips":["Pre-check disk space and output permissions","Run `unzip -t` on input APKs in CI before decode jobs","Classify the cause (read vs write) before retrying"],"tags":["apktool","baksmali","io","dex"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}