Tencent/matrix · error · TaskInitException
---params can not be null!
Error message
---params can not be null!
What it means
ApkTask.init() validates required inputs; besides the JobConfig, each task needs its params map. When the params field is null, init() throws TaskInitException with this message. Tasks receive per-run parameters (e.g. inputs, options) through this map, so running without it is treated as a configuration error.
Solutions
- Call setParams(...) with a non-null map before init(); pass at least an empty map if the task takes no options.
- Audit the job-assembly code so every registered task receives both config and params.
- For custom tasks, make params a constructor argument to make nullability impossible.
- Add a pre-run check in the job executor that asserts config and params are set for all tasks.
Example fix
// before CountRTask task = new CountRTask(); task.setConfig(jobConfig); task.init(); // after CountRTask task = new CountRTask(); task.setConfig(jobConfig); task.setParams(new HashMap<String, String>()); task.init();
Defensive patterns
Strategy: validation
Validate before calling
if (task.getParams() == null) {
task.setParams(new HashMap<String, String>());
}
task.init(); Type guard
boolean hasParams(ApkTask task) {
return task != null && task.getParams() != null;
} Try / catch
try {
task.init();
} catch (TaskInitException e) {
if (e.getMessage() != null && e.getMessage().contains("params")) {
MatrixLog.e(TAG, "params not injected for task: %s", task.getClass().getSimpleName());
}
throw e;
} Prevention
- Call setParams(...) immediately after setConfig(...) for every task.
- Pass an empty map rather than null when a task has no options.
- Centralize task construction so config+params injection happens in one place.
- Add a runner assertion that both fields are set before execute().
When it happens
Trigger: Executing an ApkTask whose setParams(...) (or equivalent) was never called before init()/execute(), or a custom task that overrides parameter injection and leaves the base field null.
Common situations: Hand-constructed tasks in tests or tooling scripts missing the params step; a refactor renaming the params setter so the old call no longer populates the field; job runner assembling tasks dynamically and skipping the params assignment for one task type.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- ---jobConfig can not be null!
- ---APK-UNZIP-PATH can not be null!
- ---APK-UNZIP-PATH ' ' is not exist!
- ---APK-UNZIP-PATH ' ' is not directory!
- ---APK-UNZIP-PATH can not be null!
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/ae0c21c7c2d08d6b.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/ApkTask.java:64
public ApkTask(JobConfig config, Map<String, String> params) {
this.params = params;
this.config = config;
progressListeners = new LinkedList<>();
}
public int getType() {
return type;
}
public void init() throws TaskInitException {
if (config == null) {
throw new TaskInitException(TAG + "---jobConfig can not be null!");
}
if (params == null) {
throw new TaskInitException(TAG + "---params can not be null!");
}
}
public void addProgressListener(ApkTaskProgressListener listener) {
if (listener != null) {
progressListeners.add(listener);
}
}
public void removeProgressListener(ApkTaskProgressListener listener) {
if (listener != null) {
progressListeners.remove(listener);
}
}
protected void notifyProgress(int progress, String message) {
for (ApkTaskProgressListener listener : progressListeners) {
listener.getProgress(progress, message);View on GitHub (pinned to 3b8293bd65)