Tencent/tinker · error · TinkerRuntimeException

listener must not be null.

Error message

listener must not be null.

What it means

Thrown by Tinker.Builder.listener when the PatchListener argument is null. The PatchListener is the entry filter for patch requests (onPatchUnused, onPatchVersionCheck, etc.) and gates whether a downloaded patch is applied; Tinker refuses to build without one rather than silently dropping patches.

Source

Thrown at tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java:408

            }
            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;
        }

        public Builder customPatcher(AbstractFilePatch patcher) {
            this.patcher = patcher;
            return this;
        }

        public Tinker build() {
            if (status == -1) {
                status = ShareConstants.TINKER_ENABLE_ALL;
            }

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Pass a non-null PatchListener such as new DefaultPatchListener(context).
  2. If custom patch filtering is not needed, use the default listener; if it is needed, implement your own subclass and pass it.
  3. Annotate the wiring method parameters @NonNull and enable nullness checks so the compiler catches this earlier.

Example fix

// before
builder.listener(null);

// after
builder.listener(new DefaultPatchListener(context));
Defensive patterns

Strategy: validation

Validate before calling

PatchListener listener = new DefaultPatchListener(context); // always non-null
builder.listener(listener);

Prevention

When it happens

Trigger: Calling builder.listener(null) — the argument came from an uninitialized field, a factory that can return null, or a copy of the Tinker sample with the DefaultPatchListener line removed.

Common situations: Migrating from the sample app and dropping the listener line because 'we patch server-driven only', DI graphs missing the PatchReporter/PatchListener binding, or Kotlin code where platform-type nullability slipped through.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/7b6aa815b4af970b. Report an issue: GitHub.