{"record":{"id":"012e03f1d46838e5","repo":"Tencent/matrix","slug":"apk-unzip-path-inputpath-is-not-directory","errorCode":null,"errorMessage":"---APK-UNZIP-PATH '<inputPath>' is not directory!","messagePattern":"---APK-UNZIP-PATH '<inputPath>' is not directory!","errorType":"exception","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/CountClassTask.java","lineNumber":84,"sourceCode":"    }\n\n    @Override\n    public void init() throws TaskInitException {\n        super.init();\n        String inputPath = config.getUnzipPath();\n\n        if (Util.isNullOrNil(inputPath)) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n\n        Log.i(TAG, \"input path:%s\", inputPath);\n\n        inputFile = new File(inputPath);\n        if (!inputFile.exists()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not exist!\");\n        }\n        if (!inputFile.isDirectory()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not directory!\");\n        }\n\n        File[] files = inputFile.listFiles();\n        try {\n            if (files != null) {\n                for (File file : files) {\n                    if (file.isFile() && file.getName().endsWith(ApkConstants.DEX_FILE_SUFFIX)) {\n                        dexFileNameList.add(file.getName());\n                        RandomAccessFile randomAccessFile = new RandomAccessFile(file, \"rw\");\n                        dexFileList.add(randomAccessFile);\n                    }\n                }\n            }\n        } catch (FileNotFoundException e) {\n            throw new TaskInitException(e.getMessage(), e);\n        }\n\n        if (params.containsKey(JobConstants.PARAM_GROUP)) {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/CountClassTask.java#L66-L102","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconfig.setUnzipPath(apkFile.getAbsolutePath()); // points at app-release.apk\n// after\nFile unzipDir = unzip(apkFile, new File(\"build/apk-unzipped\"));\nconfig.setUnzipPath(unzipDir.getAbsolutePath()); // points at extracted directory","handlingStrategy":"validation","validationCode":"File dir = new File(config.getUnzipPath());\nif (!dir.isDirectory()) {\n    throw new IllegalStateException(\"APK-UNZIP-PATH must be a directory, got: \" + dir.getAbsolutePath());\n}","typeGuard":"boolean isUnzipDir(JobConfig config) {\n    String p = config.getUnzipPath();\n    return p != null && new File(p).isDirectory();\n}","tryCatchPattern":"try {\n    countClassTask.init();\n} catch (TaskInitException e) {\n    MatrixLog.e(TAG, \"configure the extracted directory, not the apk file: %s\", e.getMessage());\n    throw e;\n}","preventionTips":["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."],"tags":["apk-canary","task-init","not-a-directory","unzip-path"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}