{"record":{"id":"869858fcc19163d5","repo":"iBotPeaches/Apktool","slug":"repeated-entry-spec-pkgid-0x-02x-typeid-0x-02x","errorCode":null,"errorMessage":"Repeated entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x","messagePattern":"Repeated entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResPackage.java","lineNumber":191,"sourceCode":"        ResEntrySpec entrySpec = mEntrySpecs.get(resId);\n        if (entrySpec == null) {\n            throw new UndefinedResObjectException(\n                String.format(\"entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x\", getId(), typeId, entryId));\n        }\n        return entrySpec;\n    }\n\n    public ResEntrySpec addEntrySpec(int typeId, int entryId, String name) throws AndrolibException {\n        ResId resId = ResId.of(getId(), typeId, entryId);\n        if (mAliases.containsKey(resId)) {\n            resId = mAliases.get(resId);\n            typeId = resId.typeId();\n            entryId = resId.entryId();\n        }\n\n        ResEntrySpec entrySpec = mEntrySpecs.get(resId);\n        if (entrySpec != null) {\n            throw new AndrolibException(\n                String.format(\"Repeated entry spec: pkgId=0x%02x, typeId=0x%02x, entryId=0x%04x\",\n                    getId(), typeId, entryId));\n        }\n\n        ResTypeSpec typeSpec = getTypeSpec(typeId);\n\n        // Some apps had their entry names obfuscated or collapsed to a single value in the key string pool.\n        // Enforce uniqueness by forcing a rename when that happens.\n        if (mNameRegistry.contains(typeSpec.getName() + \"/\" + name)) {\n            name = \"\";\n        }\n\n        entrySpec = new ResEntrySpec(typeSpec, entryId, name);\n        mEntrySpecs.put(resId, entrySpec);\n\n        // Register the name to enforce uniqueness.\n        mNameRegistry.add(typeSpec.getName() + \"/\" + entrySpec.getName());\n","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResPackage.java#L173-L209","documentation":"AndrolibException thrown by ResPackage.addEntrySpec(typeId, entryId, name) when an entry spec already exists for that resource id (after alias resolution). Each resource id may have only one entry spec; a second definition — whether from a duplicated arsc chunk or a repeated programmatic add — is rejected.","triggerScenarios":"A resources.arsc declaring the same (typeId, entryId) twice; resource-merging tools that duplicate entries; calling addEntrySpec twice for the same id; two different names mapping to one id via aliases.","commonSituations":"APKs post-processed by resource shrinkers/obfuscators that re-emit entry chunks; binary-patched arsc files; build pipelines merging multiple arsc files incorrectly.","solutions":["When adding programmatically, check for an existing spec first (getEntrySpec in a try/catch or maintain your own set) and reuse it.","Treat a genuine duplicate in a parsed file as corruption — validate the arsc with aapt2 and re-obtain the APK.","Ensure alias sources and targets do not collide with real entry ids."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"boolean alreadyPresent;\ntry { pkg.getEntrySpec(typeId, entryId); alreadyPresent = true; }\ncatch (UndefinedResObjectException e) { alreadyPresent = false; }\nif (!alreadyPresent) pkg.addEntrySpec(typeId, entryId, name);","typeGuard":null,"tryCatchPattern":"try {\n    pkg.addEntrySpec(typeId, entryId, name);\n} catch (AndrolibException ex) {\n    // duplicate entry spec in arsc -> corrupt file; abort package parse\n}","preventionTips":["Make programmatic adds idempotent (probe before add)","Keep a local set of seen resource ids when streaming the arsc","Validate suspicious arsc files with aapt2 before parsing"],"tags":["android","apktool","resource-table","duplicate","corruption"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}