Tencent/matrix · error · TaskInitException
---APK-UNZIP-PATH ' ' is not directory!
Error message
---APK-UNZIP-PATH '<inputPath>' is not directory!
What it means
CountClassTask.init() requires the configured unzip path to be a directory, not a regular file. After the existence check passes, isDirectory() is tested; if the path points to a file (e.g. the APK itself rather than its extracted contents), TaskInitException is thrown naming the path. The task walks the directory tree to count class files.
Solutions
- Point APK-UNZIP-PATH at the directory the APK was extracted into, not the .apk file.
- Confirm the unzip step produced a directory (Files.isDirectory / ls) before running the task.
- Fix the config so the unzip output directory is distinct from the APK input path.
- Add isDirectory validation in the job setup before task execution.
Example fix
// before
config.setUnzipPath(apkFile.getAbsolutePath()); // points at app-release.apk
// after
File unzipDir = unzip(apkFile, new File("build/apk-unzipped"));
config.setUnzipPath(unzipDir.getAbsolutePath()); // points at extracted directory Defensive patterns
Strategy: validation
Validate before calling
File dir = new File(config.getUnzipPath());
if (!dir.isDirectory()) {
throw new IllegalStateException("APK-UNZIP-PATH must be a directory, got: " + dir.getAbsolutePath());
} Type guard
boolean isUnzipDir(JobConfig config) {
String p = config.getUnzipPath();
return p != null && new File(p).isDirectory();
} Try / catch
try {
countClassTask.init();
} catch (TaskInitException e) {
MatrixLog.e(TAG, "configure the extracted directory, not the apk file: %s", e.getMessage());
throw e;
} Prevention
- Point APK-UNZIP-PATH at the extracted output directory, never the .apk file.
- Keep distinct config entries for APK input and unzip output.
- Check unzip tool output — it must produce a directory tree.
- Validate isDirectory() in job setup before task execution.
When it happens
Trigger: Configuring APK-UNZIP-PATH to point at the .apk file itself, or at a symlink/file instead of the extracted output directory of the unzip step.
Common situations: Confusing the APK input path with the unzip output path in the config; unzip step produced a single merged file rather than a directory; misconfigured unzip tool created a file named like the directory.
Related errors
- ---APK-UNZIP-PATH ' ' is not directory!
- ---APK-UNZIP-PATH can not be null!
- ---APK-UNZIP-PATH ' ' is not exist!
- ---APK-UNZIP-PATH can not be null!
- ---APK-UNZIP-PATH ' ' is not exist!
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/012e03f1d46838e5.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/CountClassTask.java:84
}
@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!");
}
Log.i(TAG, "input path:%s", inputPath);
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);
}
if (params.containsKey(JobConstants.PARAM_GROUP)) {View on GitHub (pinned to 3b8293bd65)