Tencent/matrix · error · TaskInitException

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

Error message

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

What it means

UnzipTask.init() requires an output directory for the unzipped APK contents. When config.getUnzipPath() is null or empty it throws TaskInitException. Without an unzip output path the task cannot extract the APK entries.

Solutions

  1. Set an output directory: config.setUnzipPath("build/matrix/unzip").
  2. Choose a directory that is either nonexistent (created in call()) or an existing directory that can be deleted/recreated.
  3. If using the matrix gradle plugin, configure the output directory in the extension before the check task runs.

Example fix

// before
config.setApkPath("app.apk");
// after
config.setApkPath("app.apk");
config.setUnzipPath("build/matrix/apk-unzip");
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

try {
    task.init();
} catch (TaskInitException e) {
    logger.error("Check unzipPath configuration: " + e.getMessage());
    throw e;
}

Prevention

When it happens

Trigger: Running the ApkCanary pipeline with an ApkCheckConfiguration that has apkPath set but unzipPath left null/empty.

Common situations: Partially filled configuration object; plugin extension where only the APK path was set; copy-pasted config where the unzip/output dir line was removed.

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/8bf3183e0ba6479d. 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:91

        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!");
            }
        }

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

View on GitHub (pinned to 3b8293bd65)