{"record":{"id":"deff8c20784fff9f","repo":"Tencent/matrix","slug":"plugin-with-tag-s-is-already-exist","errorCode":null,"errorMessage":"plugin with tag %s is already exist","messagePattern":"plugin with tag (.+?) is already exist","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/Matrix.java","lineNumber":151,"sourceCode":"\n//        private SupervisorConfig supervisorConfig;\n//        private boolean          enableFgServiceMonitor;\n//        private boolean          enableOverlayWindowMonitor;\n\n        private final HashSet<Plugin> plugins = new HashSet<>();\n\n        public Builder(Application app) {\n            if (app == null) {\n                throw new RuntimeException(\"matrix init, application is null\");\n            }\n            this.application = app;\n        }\n\n        public Builder plugin(Plugin plugin) {\n            String tag = plugin.getTag();\n            for (Plugin exist : plugins) {\n                if (tag.equals(exist.getTag())) {\n                    throw new RuntimeException(String.format(\"plugin with tag %s is already exist\", tag));\n                }\n            }\n            plugins.add(plugin);\n            return this;\n        }\n\n        public Builder pluginListener(PluginListener pluginListener) {\n            this.pluginListener = pluginListener;\n            return this;\n        }\n\n        public Builder matrixLifecycleConfig(MatrixLifecycleConfig config) {\n            this.mLifecycleConfig = config;\n            return this;\n        }\n\n        public Matrix build() {\n            if (pluginListener == null) {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/Matrix.java#L133-L169","documentation":"Thrown from Matrix.Builder.plugin() when a plugin whose getTag() matches one already registered in the Builder's internal plugin set is added. Matrix keys plugins by tag, so duplicate registration would overwrite or shadow an existing plugin configuration; this guard rejects the duplicate at build time. Typically fires when the same plugin instance or two plugins sharing a tag are added before Matrix.create is called.","triggerScenarios":"Calling builder.plugin(x) twice with the same plugin instance, or two different plugin instances whose getTag() return the same string (e.g. two TracePlugin configurations).","commonSituations":"Copy-pasted builder setup lines; a library dependency that also registers a Matrix plugin with a colliding tag; merge conflicts leaving duplicate .plugin(...) calls.","solutions":["Remove the duplicate .plugin(...) call from the Builder chain.","Use distinct tags for custom plugins by overriding getTag().","Check existing plugins before adding: skip if the tag is already present."],"exampleFix":"// before\nbuilder.plugin(tracePlugin).plugin(tracePlugin);\n// after\nbuilder.plugin(tracePlugin);","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (Plugin p : myPlugins) {\n    if (!seen.add(p.getTag())) {\n        throw new IllegalStateException(\"duplicate plugin tag: \" + p.getTag());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    builder.plugin(plugin);\n} catch (RuntimeException e) {\n    Log.e(TAG, \"duplicate plugin tag\", e);\n}","preventionTips":["Register each plugin exactly once in the Builder chain","Give custom plugins unique getTag() values","Audit third-party libraries that also add Matrix plugins"],"tags":["android","plugins","duplicate-registration"],"backgroundTag":"duplicate-registration","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}