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

  1. Call the task's config setter (setConfig / constructor parameter) with a valid non-null JobConfig before invoking init().
  2. If writing a custom task, ensure the base class field is populated by your injection code rather than shadowing it.
  3. Check the task-creation/factory code so every task added to the job receives the shared JobConfig.
  4. 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

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


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)