Tencent/tinker · error · TinkerRuntimeException
patchReporter must not be null.
Error message
patchReporter must not be null.
What it means
Thrown by Tinker.Builder.patchReporter when the argument is null. The PatchReporter receives all patch-apply (install) callbacks (onPatchResult, onPatchServiceStart, etc.), so a null value would break patch feedback. Tinker fails fast instead of deferring the failure to patch time.
Source
Thrown at tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java:397
}
this.tinkerLoadVerifyFlag = verifyMd5WhenLoad;
return this;
}
public Builder loadReport(LoadReporter loadReporter) {
if (loadReporter == null) {
throw new TinkerRuntimeException("loadReporter must not be null.");
}
if (this.loadReporter != null) {
throw new TinkerRuntimeException("loadReporter is already set.");
}
this.loadReporter = loadReporter;
return this;
}
public Builder patchReporter(PatchReporter patchReporter) {
if (patchReporter == null) {
throw new TinkerRuntimeException("patchReporter must not be null.");
}
if (this.patchReporter != null) {
throw new TinkerRuntimeException("patchReporter is already set.");
}
this.patchReporter = patchReporter;
return this;
}
public Builder listener(PatchListener listener) {
if (listener == null) {
throw new TinkerRuntimeException("listener must not be null.");
}
if (this.listener != null) {
throw new TinkerRuntimeException("listener is already set.");
}
this.listener = listener;
return this;
}View on GitHub (pinned to 1b7ea02c23)
Solutions
- Pass a non-null PatchReporter, e.g. new DefaultPatchReporter(context), in builder.patchReporter(...).
- If using DI, verify the PatchReporter binding is present and not declared @Nullable.
- Add a unit test asserting the builder receives non-null reporters before Tinker.install runs.
Example fix
// before builder.patchReporter(null); // after builder.patchReporter(new DefaultPatchReporter(context));
Defensive patterns
Strategy: validation
Validate before calling
PatchReporter reporter = createPatchReporter(context); // factory never returns null
if (reporter == null) { throw new IllegalStateException("PatchReporter binding missing"); }
builder.patchReport(reporter); Prevention
- Mark builder wiring parameters @NonNull and run nullness checks in CI.
- If using DI, make the PatchReporter binding required (not @Nullable) so missing bindings fail at graph construction.
- Unit-test the install path with a real DefaultPatchReporter.
When it happens
Trigger: Calling builder.patchReporter(null), usually because a field or constructor parameter intended to hold the PatchReporter was never initialized, or a refactor changed a method signature to return null.
Common situations: Boilerplate copied from the Tinker sample where the reporter instantiation line was deleted, Dagger/dependency-injection providing an unbound @Nullable PatchReporter, or passing a reporter that a factory method returns null for in debug builds.
Related errors
- patchReporter is already set.
- listener must not be null.
- Context must not be null.
- tinkerFlag is already set.
- tinkerLoadVerifyFlag must not be null.
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/0d2c6e2b809349b9.
Report an issue: GitHub.