Tencent/matrix · error · TaskInitException

---APK-FILE-PATH can not be null!

Error message

---APK-FILE-PATH can not be null!

What it means

UnzipTask.init() validates the APK checker configuration before unzipping. When config.getApkPath() is null or empty (Util.isNullOrNil), it throws TaskInitException with this message. The library cannot locate the APK to analyze without an input path.

Solutions

  1. Set the APK path on the configuration before running the task: config.setApkPath("/path/to/app-release.apk").
  2. If using the matrix gradle plugin, ensure the extension's apkPath/apk output is correctly configured and points at a real APK produced by an earlier build task.
  3. In CI, verify the environment variable or property feeding the APK path is populated at the time the check task runs (task ordering).

Example fix

// before
ApkCheckConfig config = new ApkCheckConfig();
// after
ApkCheckConfig config = new ApkCheckConfig();
config.setApkPath("build/outputs/apk/release/app-release.apk");
Defensive patterns

Strategy: validation

Validate before calling

if (config == null || config.getApkPath() == null || config.getApkPath().isEmpty()) {
    throw new IllegalArgumentException("apkPath must be set before running ApkCanary");
}

Try / catch

try {
    task.init();
} catch (TaskInitException e) {
    logger.error("ApkCanary misconfigured: " + e.getMessage());
    throw new GradleException("Set apkPath in the matrix extension", e);
}

Prevention

When it happens

Trigger: Calling the Matrix ApkCanary task pipeline (which invokes UnzipTask.init) with an ApkCheckConfiguration whose apkPath was never set, or set to null/empty string.

Common situations: Forgetting to call config.setApkPath() in the gradle plugin or build script; an empty APK_PATH parameter in CI; a misconfigured extension where the apk output path is resolved after the checker runs.

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


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/a2016aef9aad0357. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java:83

    private final Map<String, String> resDirMap;
    private final Map<String, String> entryNameMap;
    private final Map<String, Pair<Long, Long>> entrySizeMap;

    public UnzipTask(JobConfig config, Map<String, String> params) {
        super(config, params);
        type = TASK_TYPE_UNZIP;
        proguardClassMap = new HashMap<>();
        resguardMap = new HashMap<>();
        resDirMap = new HashMap<>();
        entryNameMap = new HashMap<>();
        entrySizeMap = new HashMap<>();
    }

    @Override
    public void init() throws TaskInitException {
        super.init();
        if (Util.isNullOrNil(config.getApkPath())) {
            throw new TaskInitException(TAG + "---APK-FILE-PATH can not be null!");
        }
        Log.i(TAG, "inputPath:%s", config.getApkPath());
        inputFile = new File(config.getApkPath());
        if (!inputFile.exists()) {
            throw new TaskInitException(TAG + "---'" + config.getApkPath() + "' is not exist!");
        }
        if (Util.isNullOrNil(config.getUnzipPath())) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH can not be null!");
        }
        Log.i(TAG, "outputPath:%s", config.getUnzipPath());
        outputFile = new File(config.getUnzipPath());

        if (!Util.isNullOrNil(config.getMappingFilePath())) {
            mappingTxt = new File(config.getMappingFilePath());
            if (!FileUtil.isLegalFile(mappingTxt)) {
                throw new TaskInitException(TAG + "---mapping file " + config.getMappingFilePath() + " is not legal!");
            }
        }

View on GitHub (pinned to 3b8293bd65)