{"record":{"id":"d350b36d70de0538","repo":"iBotPeaches/Apktool","slug":"could-not-generate","errorCode":null,"errorMessage":"Could not generate: ","messagePattern":"Could not generate: ","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/ResDecoder.java","lineNumber":163,"sourceCode":"            List<ResEntry> entries = mapEntry.getValue();\n            entries.sort(Comparator.comparing(ResEntry::getResId));\n\n            String outFileName = \"res/values\" + qualifiers + \"/\" + (typeName.endsWith(\"s\") ? typeName\n                : typeName.equals(\"^attr-private\") ? \"attrs-private\" : typeName + \"s\") + \".xml\";\n            try (OutputStream out = outDir.getFileOutput(outFileName)) {\n                serial.setOutput(out, null);\n                serial.startDocument(null, null);\n                serial.startTag(null, \"resources\");\n\n                for (ResEntry entry : entries) {\n                    // We already verified the value, cast directly.\n                    ((ValuesXmlSerializable) entry.getValue()).serializeToValuesXml(serial, entry);\n                }\n\n                serial.endTag(null, \"resources\");\n                serial.endDocument();\n            } catch (DirectoryException | IOException ex) {\n                throw new AndrolibException(\"Could not generate: \" + outFileName, ex);\n            }\n        }\n    }\n\n    private void generatePublicXml(ResPackage pkg, Directory outDir, ResXmlSerializer serial)\n            throws AndrolibException {\n        List<ResEntrySpec> specs = Lists.newArrayList(pkg.listEntrySpecs());\n        specs.sort(Comparator.comparing(ResEntrySpec::getResId));\n\n        String outFileName = \"res/values/public.xml\";\n        try (OutputStream out = outDir.getFileOutput(outFileName)) {\n            serial.setOutput(out, null);\n            serial.startDocument(null, null);\n            serial.startTag(null, \"resources\");\n\n            for (ResEntrySpec spec : specs) {\n                serial.startTag(null, \"public\");\n                serial.attribute(null, \"type\", spec.getTypeSpec().getName());","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/ResDecoder.java#L145-L181","documentation":"AndrolibException wrapping DirectoryException/IOException, thrown from ResDecoder's values-XML generation when serializing resource entries to res/values/*.xml fails. The first occurrence (line ~163) is the main values XML writer: it iterates a package's ResEntries and calls serializeToValuesXml on each; any I/O failure opening/writing the output stream, or a DirectoryException from the output Directory abstraction (missing parent dirs, file where dir expected), is rethrown with the target file name appended.","triggerScenarios":"decode() reaching values generation when the output tree is unwritable (permissions, disk full), an output path component was pre-occupied by a file, or an entry serializer hits an unexpected state producing a wrapped IOException.","commonSituations":"Out of disk during large app decode; outDir created on a read-only mount; antivirus locking generated XML files on Windows; concurrent decodes racing on the same output dir.","solutions":["Check disk space and writability of the output directory (df -h ., touch test).","Ensure no file occupies res/values paths and no other apktool process writes the same outDir.","Retry with a clean output dir (`apktool d -f`) to rule out partial-state issues."],"exampleFix":"# before\napktool d app.apk -o /readonly-mount/out\n# after\napktool d -f app.apk -o ~/work/app-out","handlingStrategy":"try-catch","validationCode":"if (!outDir.canWrite() || outDir.getUsableSpace() < 50L * 1024 * 1024) {\n    throw new IllegalStateException(\"Output dir unwritable or low on space: \" + outDir);\n}","typeGuard":null,"tryCatchPattern":"catch (AndrolibException e) { if (e.getCause() instanceof IOException io) { /* map to environment issue: space/perms, surface io.getMessage() */ } throw e; }","preventionTips":["Check disk space and writability before large decodes.","Decode into fresh directories with -f to avoid partial-state write conflicts."],"tags":["apktool","decode","io","values-xml"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}