Tencent/matrix · error · TaskInitException
---APK-UNZIP-PATH ' ' is not directory!
Error message
---APK-UNZIP-PATH '<inputPath>' is not directory!
What it means
CountRTask.init() requires the unzip path to be a directory. When the path exists but is a regular file (e.g. the .apk itself rather than its extracted contents), isDirectory() fails and TaskInitException is thrown naming the path. The task iterates the directory tree to find R.class/R$*.class files.
Solutions
- Set APK-UNZIP-PATH to the extracted APK directory, not the .apk file.
- Verify with file.isDirectory() before launching the canary job.
- Separate the config keys for APK input path and unzip output path to avoid mixups.
- Ensure the unzip step runs before CountRTask in the job pipeline.
Example fix
// before config.setUnzipPath(inputApk.getAbsolutePath()); // after File unzipDir = new File(inputApk.getParent(), "unzipped"); unzip(inputApk, unzipDir); config.setUnzipPath(unzipDir.getAbsolutePath());
Defensive patterns
Strategy: validation
Validate before calling
File dir = new File(config.getUnzipPath());
if (!dir.isDirectory()) {
throw new IllegalStateException("APK-UNZIP-PATH must be the extracted directory: " + dir.getAbsolutePath());
} Type guard
boolean isUnzipDir(JobConfig config) {
String p = config.getUnzipPath();
return p != null && new File(p).isDirectory();
} Try / catch
try {
countRTask.init();
} catch (TaskInitException e) {
MatrixLog.e(TAG, "point APK-UNZIP-PATH at the extracted dir: %s", e.getMessage());
throw e;
} Prevention
- Never pass the .apk file path as the unzip path.
- Derive the unzip directory from the unzip task's output rather than manual config.
- Validate isDirectory() before executing resource-counting tasks.
- Separate and document the APK-input vs unzip-output config keys.
When it happens
Trigger: Configuring APK-UNZIP-PATH for CountRTask to the .apk file or any regular file instead of the directory produced by the unzip step.
Common situations: Mixing up the APK input and unzipped-output configuration entries; unzip step writing a single file; symlink resolved to a file; copy/paste of the APK path into the unzip-path field.
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/87be517f41f90c15.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/CountRTask.java:78
dexFileList = new ArrayList<>();
classesMap = new HashMap<>();
}
@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 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);
}
}View on GitHub (pinned to 3b8293bd65)