{"record":{"id":"fa4084506dfaa802","repo":"Tencent/tinker","slug":"patchreporter-must-not-be-null","errorCode":null,"errorMessage":"patchReporter must not be null.","messagePattern":"patchReporter must not be null\\.","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java","lineNumber":346,"sourceCode":"            }\n            this.tinkerLoadVerifyFlag = verifyMd5WhenLoad;\n            return this;\n        }\n\n        public Builder loadReport(LoadReporter loadReporter) {\n            if (loadReporter == null) {\n                throw new TinkerRuntimeException(\"loadReporter must not be null.\");\n            }\n            if (this.loadReporter != null) {\n                throw new TinkerRuntimeException(\"loadReporter is already set.\");\n            }\n            this.loadReporter = loadReporter;\n            return this;\n        }\n\n        public Builder patchReporter(PatchReporter patchReporter) {\n            if (patchReporter == null) {\n                throw new TinkerRuntimeException(\"patchReporter must not be null.\");\n            }\n            if (this.patchReporter != null) {\n                throw new TinkerRuntimeException(\"patchReporter is already set.\");\n            }\n            this.patchReporter = patchReporter;\n            return this;\n        }\n\n        public Builder listener(PatchListener listener) {\n            if (listener == null) {\n                throw new TinkerRuntimeException(\"listener must not be null.\");\n            }\n            if (this.listener != null) {\n                throw new TinkerRuntimeException(\"listener is already set.\");\n            }\n            this.listener = listener;\n            return this;\n        }","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java#L328-L364","documentation":"Tinker.Builder.patchReporter(PatchReporter) throws TinkerRuntimeException(\"patchReporter must not be null.\") when passed a null PatchReporter. The patch reporter receives patch-application callbacks (try patch, patch success/failure, rollback) and is mandatory in a Tinker configuration; the builder fails fast on null instead of leaving patch failures unreported.","triggerScenarios":"Calling patchReporter(null) — a null field at chain time due to constructor ordering (reporter needs the Application, which is not ready), a flavor-specific reporter not created in that variant, or an argument dropped during refactor.","commonSituations":"Init code in attachBaseContext referencing a reporter field assigned only in onCreate; unit tests or demo samples omitting reporters; upgrading Tinker versions where constructor signatures changed and a reporter instantiation was removed.","solutions":["Create the PatchReporter into a local (e.g. new DefaultPatchReporter(getApplicationContext())) and pass that; assert non-null before the chain.","Order initialization so the Application context exists before building Tinker config.","In tests use a no-op PatchReporter subclass rather than null."],"exampleFix":"// before\nbuilder.patchReporter(patchReporter); // field null at this point\n\n// after\nPatchReporter patchReporter = new DefaultPatchReporter(getApplicationContext());\nbuilder.patchReporter(patchReporter);","handlingStrategy":"validation","validationCode":"PatchReporter patchReporter = (customReporter != null)\n        ? customReporter\n        : new DefaultPatchReporter(getApplicationContext());\nbuilder.patchReporter(patchReporter);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Instantiate reporters from the application context before building config","Use no-op reporter subclasses in tests instead of null"],"tags":["android","tinker","builder","null-check","reporter"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}