Tencent/matrix · error · TaskExecuteException

---Create directory '<outputFile.getAbsolutePath()>' failed!

Error message

---Create directory '<outputFile.getAbsolutePath()>' failed!

What it means

In UnzipTask.call(), after validating the output path, the task calls outputFile.mkdir(); if directory creation fails it throws TaskExecuteException. mkdir() fails when the parent directory doesn't exist, or the process lacks write permission on the parent.

Solutions

  1. Pre-create parent directories (mkdir -p) or configure a single-level output directory.
  2. Check write permissions on the parent of the configured unzip path and fix them.
  3. Point unzipPath at a writable location inside the project build directory.

Example fix

// before
config.setUnzipPath("build/a/b/c/unzip"); // parents missing
// after
new File("build/a/b/c").mkdirs();
config.setUnzipPath("build/a/b/c/unzip");
Defensive patterns

Strategy: try-catch

Validate before calling

File out = new File(config.getUnzipPath());
File parent = out.getAbsoluteFile().getParentFile();
if (parent != null) parent.mkdirs();
if (!parent.canWrite()) {
    throw new IllegalArgumentException("Cannot write to " + parent);
}

Try / catch

try {
    task.call();
} catch (TaskExecuteException e) {
    if (e.getMessage().contains("Create directory")) {
        throw new GradleException("Fix permissions / create parent dirs for unzipPath", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: config.getUnzipPath() has a nonexistent parent directory (mkdir() creates only one level), or the user running the build cannot write to the parent.

Common situations: Deep output path whose intermediate directories don't exist; read-only CI workspace; sandboxed/permission-restricted runner; path on a read-only mounted volume.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/e3e8909213cd5745. 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:254

    @Override
    public TaskResult call() throws TaskExecuteException {
        ZipFile zipFile = null;
        try {
            zipFile = new ZipFile(inputFile);
            if (outputFile.isDirectory() && outputFile.exists()) {
                Log.i(TAG, "%s exists, delete it.", outputFile.getAbsolutePath());
                FileUtils.deleteDirectory(outputFile);
            } else if (outputFile.isFile()) {
                throw new TaskExecuteException(TAG + "---File '" + outputFile.getAbsolutePath() + "' is already exists!");
            }
            TaskResult taskResult = TaskResultFactory.factory(getType(), TASK_RESULT_TYPE_JSON, config);
            if (taskResult == null) {
                return null;
            }
            long startTime = System.currentTimeMillis();
            if (!outputFile.mkdir()) {
                throw new TaskExecuteException(TAG + "---Create directory '" + outputFile.getAbsolutePath() + "' failed!");
            }

            ((TaskJsonResult) taskResult).add("total-size", inputFile.length());

            readMappingTxtFile();
            config.setProguardClassMap(proguardClassMap);
            ResguardUtil.readResMappingTxtFile(resMappingTxt, resDirMap, resguardMap);
            config.setResguardMap(resguardMap);

            Enumeration entries = zipFile.entries();
            JsonArray jsonArray = new JsonArray();
            String outEntryName = "";
            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry) entries.nextElement();
                outEntryName = writeEntry(zipFile, entry);
                if (!Util.isNullOrNil(outEntryName)) {
                    JsonObject fileItem = new JsonObject();
                    fileItem.addProperty("entry-name", outEntryName);

View on GitHub (pinned to 3b8293bd65)