Tencent/matrix · error · TaskInitException
---jobConfig can not be null!
Error message
---jobConfig can not be null!
What it means
ApkTask is the base class for APK canary checker tasks. init() validates that the task has been given a JobConfig before running; if the config field is null it throws TaskInitException with this message. This is a fail-fast guard so tasks never execute unconfigured.
Solutions
- Call the task's config setter (setConfig / constructor parameter) with a valid non-null JobConfig before invoking init().
- If writing a custom task, ensure the base class field is populated by your injection code rather than shadowing it.
- Check the task-creation/factory code so every task added to the job receives the shared JobConfig.
- Add an assertion or unit test asserting task.getConfig() != null before job execution.
Example fix
// before ApkTask task = new CountClassTask(); task.init(); // after ApkTask task = new CountClassTask(); task.setConfig(jobConfig); task.setParams(params); task.init();
Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(task, "task");
if (task.getConfig() == null) {
throw new IllegalStateException("JobConfig missing for task before init()");
} Type guard
boolean isConfigured(ApkTask task) {
return task != null && task.getConfig() != null;
} Try / catch
try {
task.init();
} catch (TaskInitException e) {
MatrixLog.e(TAG, "task init failed: %s", e.getMessage());
throw e; // config errors should fail the job fast
} Prevention
- Always pair task creation with setConfig(...) in your factory/runner code.
- Write a unit test that initializes every registered ApkTask with a real JobConfig.
- Make config a constructor parameter in custom tasks.
- Fail the job at assembly time if any task lacks a config.
When it happens
Trigger: Registering/executing an ApkTask subclass without calling its setter (or constructor path) that supplies the JobConfig — i.e. the task executor ran init() on a task whose config was never assigned.
Common situations: Custom ApkTask implementations that override how config is injected and forget to set it; programmatically constructing a task and calling execute()/init() directly without calling the config setter; framework wiring changes that drop config propagation.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- ---params can not be null!
- ---APK-UNZIP-PATH can not be null!
- ---APK-UNZIP-PATH can not be null!
- ---APK-UNZIP-PATH ' ' is not exist!
- ---APK-UNZIP-PATH ' ' is not directory!
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/8846be3de982f04f.
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:60
public interface ApkTaskProgressListener {
void getProgress(int progress, String message);
}
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);
}
}View on GitHub (pinned to 3b8293bd65)