Tencent/matrix · error · TaskExecuteException

e.getMessage()

Error message

e.getMessage()

What it means

UnusedAssetsTask.call() wraps any Exception thrown while scanning the unzipped APK for unused assets into a TaskExecuteException, using e.getMessage() as the message. The original exception is kept as the cause. It is a generic execution-failure wrapper, so the real reason is in the cause.

Solutions

  1. Read the cause (TaskExecuteException.getCause()) — the message is just the cause's getMessage() and may be null
  2. Verify the APK was fully unzipped and the unzip path is a readable directory
  3. Check file permissions of the extracted assets
  4. Re-run the ApkChecker job with a fresh unzipped APK directory

Example fix

// before
throw new TaskExecuteException(e.getMessage(), e);
// after
throw new TaskExecuteException("UnusedAssetsTask failed: " + e, e);
Defensive patterns

Strategy: try-catch

Validate before calling

File unzipDir = new File(config.getUnzipPath());
if (unzipDir == null || !unzipDir.isDirectory() || !unzipDir.canRead()) throw new IllegalStateException("unzip path invalid");

Try / catch

try {
    TaskResult r = task.call();
} catch (TaskExecuteException e) {
    Throwable cause = e.getCause();
    log.error("unused-assets failed", cause != null ? cause : e);
}

Prevention

When it happens

Trigger: Any exception during execute() of UnusedAssetsTask: IO errors reading files under the unzip path, failures building the file graph, or JSON result assembly errors.

Common situations: Corrupted or partially extracted APK directory, unreadable asset files (permissions), disk errors, or a bug in a downstream task step during Gradle APK analyses.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

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

            TaskResult taskResult = TaskResultFactory.factory(type, TaskResultFactory.TASK_RESULT_TYPE_JSON, config);
            long startTime = System.currentTimeMillis();
            File assetDir = new File(inputFile, ApkConstants.ASSETS_DIR_NAME);
            findAssetsFile(assetDir);
            generateAssetsSet(assetDir.getAbsolutePath());
            Log.i(TAG, "find all assets count: %d", assetsPathSet.size());
            decodeCode();
            Log.i(TAG, "find reference assets count: %d", assetRefSet.size());
            assetsPathSet.removeAll(assetRefSet);
            JsonArray jsonArray = new JsonArray();
            for (String name : assetsPathSet) {
                jsonArray.add(name);
            }
            ((TaskJsonResult) taskResult).add("unused-assets", jsonArray);
            taskResult.setStartTime(startTime);
            taskResult.setEndTime(System.currentTimeMillis());
            return taskResult;
        } catch (Exception e) {
            throw new TaskExecuteException(e.getMessage(), e);
        }
    }
}

View on GitHub (pinned to 3b8293bd65)