Tencent/matrix · error · TaskInitException

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

Error message

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

What it means

FindNonAlphaPngTask.init() throws TaskInitException when the unzip path exists but is a regular file rather than a directory. The task iterates files under the directory (res/, assets/) looking for PNGs, so a file path breaks traversal assumptions.

Solutions

  1. Point --unzip at the directory containing the extracted APK contents (with res/, AndroidManifest.xml).
  2. Run UnzipTask/unzip first and pass its output directory.
  3. Validate with `test -d <path>` in your build script before invoking the checker.

Example fix

// before
config.setUnzipPath(apkFilePath); // wrong: file, not dir
// after
config.setUnzipPath(extractedDir.getAbsolutePath()); // output of unzip step
Defensive patterns

Strategy: validation

Validate before calling

File dir = new File(config.getUnzipPath());
if (dir.exists() && !dir.isDirectory()) {
    throw new IllegalStateException("unzip path is a file, expected directory: " + dir);
}

Try / catch

try {
    task.init();
} catch (TaskInitException e) {
    if (e.getMessage().contains("is not directory")) {
        config.setUnzipPath(extractedDir.getAbsolutePath());
    }
}

Prevention

When it happens

Trigger: config.getUnzipPath() points to an existing file (e.g. the APK itself or a single file) instead of the unzipped APK root directory.

Common situations: Passing the .apk path to --unzip instead of --apk; pointing at a lone extracted file; misconfigured CI variables mixing artifact and extraction paths.

Related errors


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

Appendix: source

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

    private Map<String, String> entryNameMap;

    public FindNonAlphaPngTask(JobConfig config, Map<String, String> params) {
        super(config, params);
        type = TASK_TYPE_FIND_NON_ALPHA_PNG;
    }

    @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 exists!");
        } else if (!inputFile.isDirectory()) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH '" + inputPath + "' is not directory!");
        }
        if (params.containsKey(JobConstants.PARAM_MIN_SIZE_IN_KB)) {
            try {
                downLimitSize = Long.parseLong(params.get(JobConstants.PARAM_MIN_SIZE_IN_KB));
            } catch (NumberFormatException e) {
                Log.e(TAG, "DOWN-LIMIT-SIZE '" + params.get(JobConstants.PARAM_MIN_SIZE_IN_KB) + "' is not number format!");
            }
        }
        nonAlphaPngList = new ArrayList<Pair<String, Long>>();
        entrySizeMap = config.getEntrySizeMap();
        entryNameMap = config.getEntryNameMap();
    }

    private void findNonAlphaPng(File file) throws IOException {
        if (file != null) {
            if (file.isDirectory()) {
                File[] files = file.listFiles();
                for (File tempFile : files) {

View on GitHub (pinned to 3b8293bd65)