{"record":{"id":"24ec6185bea9f57c","repo":"Tencent/matrix","slug":"apk-unzip-path-inputpath-is-not-directory-24ec61","errorCode":null,"errorMessage":"---APK-UNZIP-PATH '<inputPath>' is not directory!","messagePattern":"---APK-UNZIP-PATH '<inputPath>' is not directory!","errorType":"validation","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/MethodCountTask.java","lineNumber":92,"sourceCode":"        classInternalMethod = new HashMap<String, Integer>();\n        classExternalMethod = new HashMap<String, Integer>();\n        pkgInternalRefMethod = new HashMap<String, Integer>();\n        pkgExternalMethod = new HashMap<String, Integer>();\n    }\n\n    @Override\n    public void init() throws TaskInitException {\n        super.init();\n        String inputPath = config.getUnzipPath();\n        if (Util.isNullOrNil(inputPath)) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        Log.i(TAG, \"input path:%s\", inputPath);\n        inputFile = new File(inputPath);\n        if (!inputFile.exists()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not exist!\");\n        } else if (!inputFile.isDirectory()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not directory!\");\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        if (params.containsKey(JobConstants.PARAM_GROUP)) {\n            if (JobConstants.GROUP_PACKAGE.equals(params.get(JobConstants.PARAM_GROUP))) {\n                group = JobConstants.GROUP_PACKAGE;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/MethodCountTask.java#L74-L110","documentation":"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.","triggerScenarios":"config.getUnzipPath() points to the APK file itself (or any file) instead of the directory the APK was unzipped into when MethodCountTask.init() executes.","commonSituations":"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.","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."],"exampleFix":"// before\nconfig.setUnzipPath(\"/tmp/build/app-release.apk\"); // is a file\n// after\nconfig.setUnzipPath(\"/tmp/build/app-release-unzipped\"); // directory with lib/, classes.dex etc.","handlingStrategy":"validation","validationCode":"File dir = new File(config.getUnzipPath());\nif (dir.exists() && !dir.isDirectory()) {\n    throw new IllegalStateException(\"unzip path must be a directory, not a file: \" + dir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    if (e.getMessage().contains(\"is not directory\")) {\n        // pass the unzipped directory instead of the .apk file\n    }\n}","preventionTips":["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."],"tags":["config","filesystem","apk-canary"],"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"}