Tencent/matrix · error · TaskInitException

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

Error message

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

What it means

DuplicateFileTask.init() throws TaskInitException when the unzip path exists but is a file, not a directory. The task expects the root of an unzipped APK (directories like res/, assets/) to walk for duplicate files.

Solutions

  1. Pass the unzipped APK directory (containing AndroidManifest.xml, res/, etc.), not the .apk file.
  2. Check with `file <path>` / `ls -la <path>` and point --unzip at the directory created by the unzip step.
  3. Re-run the unzip step to regenerate the directory if it was replaced.

Example fix

// before
config.setUnzipPath("/build/app-release.apk"); // it's a file
// after
config.setUnzipPath("/build/unzipped-apk/"); // directory produced by UnzipTask
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

try {
    task.init();
} catch (TaskInitException e) {
    if (e.getMessage().contains("is not directory")) {
        // reconfigure to point at the extracted directory instead of the apk file
        config.setUnzipPath(extractedDir.getAbsolutePath());
    }
}

Prevention

When it happens

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

Common situations: Passing the APK file path where the unzipped directory is expected; confusing --apk input with --unzip output in ApkChecker CLI; a changed unzip layout after a tool version update.

Related errors


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

Appendix: source

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

    private Map<String, String> entryNameMap;

    public DuplicateFileTask(JobConfig config, Map<String, String> params) {
        super(config, params);
        type = TaskFactory.TASK_TYPE_DUPLICATE_FILE;
    }

    @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!");
        }
        md5Map = new HashMap<>();
        fileSizeList = new ArrayList<>();
        entrySizeMap = config.getEntrySizeMap();
        entryNameMap = config.getEntryNameMap();
    }

    private void computeMD5(File file) throws NoSuchAlgorithmException, IOException {
        if (file != null) {
            if (file.isDirectory()) {
                File[] files = file.listFiles();
                for (File resFile : files) {
                    computeMD5(resFile);
                }
            } else {
                MessageDigest msgDigest = MessageDigest.getInstance("MD5");
                BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(file));
                byte[] buffer = new byte[512];

View on GitHub (pinned to 3b8293bd65)