Tencent/matrix · error · TaskInitException

---APK-UNZIP-PATH ' ' is not exist!

Error message

---APK-UNZIP-PATH '<inputPath>' is not exist!

What it means

CountRTask.init() checks that the configured unzip path exists on disk. If the File constructed from config.getUnzipPath() does not exist, it throws TaskInitException that names the missing path. The task needs the extracted APK directory to scan for R classes.

Solutions

  1. Re-run the unzip step and confirm the target directory exists before executing CountRTask.
  2. Configure an absolute path via config.setUnzipPath(file.getAbsolutePath()).
  3. Make unzip failures fatal so the check tasks are skipped when the directory is missing.
  4. Print the absolute path of the configured value in logs to catch typos and wrong working directories.

Example fix

// before
config.setUnzipPath("/tmp/old-build/unzipped"); // deleted by CI clean
// after
File dir = new File("build/apk-unzipped");
if (!dir.exists()) {
    dir = unzipApkTask.run();
}
config.setUnzipPath(dir.getAbsolutePath());
Defensive patterns

Strategy: validation

Validate before calling

File dir = new File(config.getUnzipPath());
if (!dir.exists()) {
    unzipStep.run(); // recreate the extracted directory
}
if (!dir.exists()) {
    throw new IllegalStateException("unzip dir still missing: " + dir.getAbsolutePath());
}

Type guard

boolean unzipDirExists(JobConfig config) {
    String p = config.getUnzipPath();
    return p != null && new File(p).exists();
}

Try / catch

try {
    countRTask.init();
} catch (TaskInitException e) {
    MatrixLog.e(TAG, "unzip path missing, re-running unzip step: %s", e.getMessage());
    throw e;
}

Prevention

When it happens

Trigger: CountRTask run with APK-UNZIP-PATH pointing to a directory that was never created (unzip failed/skipped), removed by a clean, or given with a typo/relative path resolved against a different working directory.

Common situations: CI cleaning intermediate outputs between steps; unzip step silently failing; relative path used while the checker runs from another directory; reusing a cached config from a previous machine.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

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

        super(config, params);
        type = TASK_TYPE_COUNT_R_CLASS;
        dexFileNameList = new ArrayList<>();
        dexFileList = new ArrayList<>();
        classesMap = new HashMap<>();
    }

    @Override
    public void init() throws TaskInitException {
        super.init();
        String inputPath = config.getUnzipPath();

        if (Util.isNullOrNil(inputPath)) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH can not be null!");
        }

        inputFile = new File(inputPath);
        if (!inputFile.exists()) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH '" + inputPath + "' is not exist!");
        }
        if (!inputFile.isDirectory()) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH '" + inputPath + "' is not directory!");
        }

        File[] files = inputFile.listFiles();
        try {
            if (files != null) {
                for (File file : files) {
                    if (file.isFile() && file.getName().endsWith(ApkConstants.DEX_FILE_SUFFIX)) {
                        dexFileNameList.add(file.getName());
                        RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                        dexFileList.add(randomAccessFile);
                    }
                }
            }
        } catch (FileNotFoundException e) {
            throw new TaskInitException(e.getMessage(), e);

View on GitHub (pinned to 3b8293bd65)