{"record":{"id":"a4e0e702f204e273","repo":"Tencent/matrix","slug":"apk-unzip-path-inputpath-is-not-directory-a4e0e7","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/UnusedResourcesTask.java","lineNumber":118,"sourceCode":"    public void init() throws TaskInitException {\n        super.init();\n\n        String inputPath = config.getUnzipPath();\n        if (Util.isNullOrNil(inputPath)) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        if (!params.containsKey(JobConstants.PARAM_R_TXT) || Util.isNullOrNil(params.get(JobConstants.PARAM_R_TXT))) {\n            throw new TaskInitException(TAG + \"---The File 'R.txt' can not be null!\");\n        }\n        resourceTxt = new File(params.get(JobConstants.PARAM_R_TXT));\n        if (!FileUtil.isLegalFile(resourceTxt)) {\n            throw new TaskInitException(TAG + \"---The Resource declarations file 'R.txt' is not legal!\");\n        }\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        if (!Util.isNullOrNil(config.getMappingFilePath())) {\n            mappingTxt = new File(config.getMappingFilePath());\n            if (!FileUtil.isLegalFile(mappingTxt)) {\n                throw new TaskInitException(TAG + \"---The Proguard mapping file 'mapping.txt' is not legal!\");\n            }\n        }\n        if (params.containsKey(JobConstants.PARAM_IGNORE_RESOURCES_LIST) && !Util.isNullOrNil(params.get(JobConstants.PARAM_IGNORE_RESOURCES_LIST))) {\n            String[] ignoreRes = params.get(JobConstants.PARAM_IGNORE_RESOURCES_LIST).split(\",\");\n            for (String ignore : ignoreRes) {\n                ignoreSet.add(Util.globToRegexp(ignore));\n            }\n        }\n        if (!Util.isNullOrNil(config.getResMappingFilePath())) {\n            resMappingTxt = new File(config.getResMappingFilePath());\n            if (!FileUtil.isLegalFile(resMappingTxt)) {\n                throw new TaskInitException(TAG + \"---The Resguard mapping file 'resguard-mapping.txt' is not legal!\");\n            }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnusedResourcesTask.java#L100-L136","documentation":"Thrown from UnusedResourcesTask.init() when the configured unzip path exists but is not a directory. The task requires the extracted APK's directory tree (with res/ contents) to check for unused resources; supplying a file path triggers this TaskInitException.","triggerScenarios":"config.getUnzipPath() points to the .apk itself or some other file instead of the extraction output directory.","commonSituations":"Confusing the APK artifact path with the unzipped output path in Gradle plugin config or CLI -unzip argument.","solutions":["Point unzip path to the extracted APK directory produced by the unzip task","If you only have the .apk, extract it first (unzip apk -d dir) and use dir","Log/print the configured path and confirm its type"],"exampleFix":"// before\nconfig.setUnzipPath(\"/build/outputs/apk/release/app-release.apk\");\n// after\nconfig.setUnzipPath(\"/build/outputs/apk/release/apk-extracted\"); // must be a directory","handlingStrategy":"validation","validationCode":"File dir = new File(config.getUnzipPath());\nif (dir.exists() && !dir.isDirectory()) throw new IllegalStateException(\"unzip path must be a directory\");","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    log.error(\"unzip path is not a directory: \" + e.getMessage());\n}","preventionTips":["Never pass the .apk file as unzip path","Name the extraction dir explicitly and reuse it across tasks","Add a pre-flight assert: path exists && isDirectory"],"tags":["android","apk-analysis","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"}