Tencent/matrix · error · TaskInitException
---APK-UNZIP-PATH ' ' is not directory!
Error message
---APK-UNZIP-PATH '<inputPath>' is not directory!
What it means
MethodCountTask.init() requires the configured unzip path to be a directory (it iterates over it looking for .dex files). If the path exists but is a regular file, init throws TaskInitException with this message.
Solutions
- Point the unzip path at the directory containing the extracted APK contents, not the .apk file.
- Unzip the APK first and use that output directory in the config.
- Add a pre-run check: new File(path).isDirectory() before configuring the task.
Example fix
// before
config.setUnzipPath("/tmp/build/app-release.apk"); // is a file
// after
config.setUnzipPath("/tmp/build/app-release-unzipped"); // directory with lib/, classes.dex etc. 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, not a file: " + dir);
} Try / catch
try {
task.init();
} catch (TaskInitException e) {
if (e.getMessage().contains("is not directory")) {
// pass the unzipped directory instead of the .apk file
}
} Prevention
- Remember unzipPath means the EXTRACTED directory, never the .apk artifact.
- Check isDirectory() on the configured path in your build script.
- Name conventions: keep APK artifact path and unzip output path as separate config keys.
When it happens
Trigger: config.getUnzipPath() points to the APK file itself (or any file) instead of the directory the APK was unzipped into when MethodCountTask.init() executes.
Common situations: Developers pass the .apk file path directly instead of the unzipped directory; a previous task set unzipPath to the APK artifact path; confusion between input APK path and unpacked output path.
Related errors
- ---APK-UNZIP-PATH ' ' is not exist!
- ---APK-UNZIP-PATH can not be null!
- TAG + "---The path of tool 'nm' is not given!"
- TAG + "---APK-UNZIP-PATH can not be null!"
- TAG + "---APK-FILE-PATH can not be null!"
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/24ec6185bea9f57c.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/MethodCountTask.java:92
classInternalMethod = new HashMap<String, Integer>();
classExternalMethod = new HashMap<String, Integer>();
pkgInternalRefMethod = new HashMap<String, Integer>();
pkgExternalMethod = new HashMap<String, Integer>();
}
@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!");
} else 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)) {
if (JobConstants.GROUP_PACKAGE.equals(params.get(JobConstants.PARAM_GROUP))) {
group = JobConstants.GROUP_PACKAGE;View on GitHub (pinned to 3b8293bd65)