{"record":{"id":"7ec1f7e57682e397","repo":"Tencent/tinker","slug":"unexpected-xml-parser-state-when-parsing-increment","errorCode":null,"errorMessage":"unexpected xml parser state when parsing incremental component manifest.","messagePattern":"unexpected xml parser state when parsing incremental component manifest\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/IncrementComponentManager.java","lineNumber":83,"sourceCode":"            }\n        }\n\n        void onInit(Context context, int tagType, XmlPullParser parser) {\n            // Do nothing.\n        }\n\n        abstract void onTranslate(Context context, int tagType, String attrName, String attrValue, T_RESULT result);\n    }\n\n    private static final AttrTranslator<ActivityInfo> ACTIVITY_INFO_ATTR_TRANSLATOR = new AttrTranslator<ActivityInfo>() {\n\n        @Override\n        void onInit(Context context, int tagType, XmlPullParser parser) {\n            try {\n                if (tagType == TAG_ACTIVITY\n                        && (parser.getEventType() != XmlPullParser.START_TAG\n                        || !\"activity\".equals(parser.getName()))) {\n                    throw new IllegalStateException(\"unexpected xml parser state when parsing incremental component manifest.\");\n                }\n            } catch (XmlPullParserException e) {\n                throw new IllegalStateException(e);\n            }\n        }\n\n        @Override\n        void onTranslate(Context context, int tagType, String attrName, String attrValue, ActivityInfo result) {\n            if (\"name\".equals(attrName)) {\n                if (attrValue.charAt(0) == '.') {\n                    result.name = context.getPackageName() + attrValue;\n                } else {\n                    result.name = attrValue;\n                }\n            } else if (\"parentActivityName\".equals(attrName)) {\n                if (Build.VERSION.SDK_INT >= 16) {\n                    if (attrValue.charAt(0) == '.') {\n                        result.parentActivityName = context.getPackageName() + attrValue;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/IncrementComponentManager.java#L65-L101","documentation":"When translating the incremental component manifest, the ActivityInfo AttrTranslator asserts the XmlPullParser is positioned on a START_TAG named 'activity' whenever it sees TAG_ACTIVITY. This IllegalStateException means the parser's event/position contradicted the tag type being processed — the manifest stream does not have the expected structure.","triggerScenarios":"Malformed component manifest inside the patch (dex/metadata), or a manifest generated by a patch tool whose element ordering/structure differs from what this parser expects (tool/loader version mismatch).","commonSituations":"Patch built with an old/new Tinker gradle plugin loaded by a mismatched SDK; hand-edited or truncated component manifest files in the patch package.","solutions":["Rebuild the patch with the Tinker gradle plugin version exactly matching the SDK in the app.","Do not hand-modify patch contents; repackage through the official build flow.","If recurring, catch the exception during patch load and reject/disable the patch server-side."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before shipping patch: validate the component manifest parses\n// XmlPullParser over patch dex/component manifest in a unit test\n// using the same SDK version as the app","typeGuard":null,"tryCatchPattern":"try {\n    IncrementComponentManager.commitInstalled(...);\n} catch (IllegalStateException e) {\n    // malformed incremental manifest: reject this patch, keep previous\n}","preventionTips":["Use matching gradle-plugin/SDK versions to generate and consume patches.","Automate a patch-validation step in CI (parse component manifest with the loader's parser).","Never hand-edit files inside the built patch package."],"tags":["android","xml-parsing","manifest","hotplug","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}