{"record":{"id":"4d5006c3df61568a","repo":"iBotPeaches/Apktool","slug":"type-spec-pkgid-0x-02x-typeid-0x-02x","errorCode":null,"errorMessage":"type spec: pkgId=0x%02x, typeId=0x%02x","messagePattern":"type spec: pkgId=0x%02x, typeId=0x%02x","errorType":"exception","errorClass":"UndefinedResObjectException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResPackage.java","lineNumber":82,"sourceCode":"        return mGroup.getId();\n    }\n\n    public String getName() {\n        return mGroup.getName();\n    }\n\n    public int getIndex() {\n        return mIndex;\n    }\n\n    public boolean hasTypeSpec(int typeId) {\n        return mTypeSpecs.containsKey(typeId);\n    }\n\n    public ResTypeSpec getTypeSpec(int typeId) throws UndefinedResObjectException {\n        ResTypeSpec typeSpec = mTypeSpecs.get(typeId);\n        if (typeSpec == null) {\n            throw new UndefinedResObjectException(\n                String.format(\"type spec: pkgId=0x%02x, typeId=0x%02x\", getId(), typeId));\n        }\n        return typeSpec;\n    }\n\n    public ResTypeSpec addTypeSpec(int typeId, String typeName) throws AndrolibException {\n        ResTypeSpec typeSpec = mTypeSpecs.get(typeId);\n        if (typeSpec != null) {\n            throw new AndrolibException(\n                String.format(\"Repeated type spec: pkgId=0x%02x, typeId=0x%02x, typeName=%s\",\n                    getId(), typeId, typeName));\n        }\n\n        typeSpec = new ResTypeSpec(this, typeId, typeName);\n        mTypeSpecs.put(typeId, typeSpec);\n        return typeSpec;\n    }\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResPackage.java#L64-L100","documentation":"UndefinedResObjectException thrown by ResPackage.getTypeSpec(typeId) when no ResTypeSpec exists for the given type id in this package. Type specs are created from RES_TABLE_TYPE_SPEC chunks in resources.arsc; the error means a resource reference resolves to a typeId that was never declared for the package — a mismatch between the resource table metadata and the code/data using it.","triggerScenarios":"Calling getTypeSpec with a typeId from a resource id whose package id does not match this ResPackage; obfuscated arsc with stripped type spec chunks; referencing a type that only exists in a split APK's resources.arsc; calling addEntry (which internally calls getTypeSpec) for a type never added via addTypeSpec.","commonSituations":"Decoding app bundles where types are spread across splits; aggressively obfuscated APKs (resource name/ID remapping tools); programmatic resource-table construction that forgets addTypeSpec before adding entries; cross-package lookups that forget to select the right package.","solutions":["Guard with hasTypeSpec(typeId) before calling getTypeSpec(typeId).","Verify you are using the correct ResPackage for the resource id: the high byte of the id must equal package.getId().","When building a table programmatically, always call addTypeSpec(typeId, typeName) before addType/addEntry for that type.","For split/bundle APKs, decode the base APK together with its splits so all type specs are loaded."],"exampleFix":"// before\nResTypeSpec spec = pkg.getTypeSpec(typeId); // throws if absent\n\n// after\nif (!pkg.hasTypeSpec(typeId)) {\n    throw new IllegalArgumentException(\"type 0x\" + Integer.toHexString(typeId) + \" not in package 0x\" + Integer.toHexString(pkg.getId()));\n}\nResTypeSpec spec = pkg.getTypeSpec(typeId);","handlingStrategy":"type-guard","validationCode":"int pkgId = (resId >>> 24) & 0xff;\nif (pkgId != resPackage.getId()) {\n    throw new IllegalArgumentException(\"resource id belongs to package 0x\" + Integer.toHexString(pkgId));\n}","typeGuard":"boolean hasTypeSpec(ResPackage pkg, int typeId) {\n    return pkg.hasTypeSpec(typeId);\n}","tryCatchPattern":"try {\n    ResTypeSpec spec = pkg.getTypeSpec(typeId);\n} catch (UndefinedResObjectException ex) {\n    // type never declared for this package; skip resource\n}","preventionTips":["Always call hasTypeSpec() before getTypeSpec()","Match the resource id's package byte to the ResPackage before lookups","When building tables, addTypeSpec before any addType/addEntry for that typeId"],"tags":["android","apktool","resource-table","undefined-object","obfuscation"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}