{"record":{"id":"a2016aef9aad0357","repo":"Tencent/matrix","slug":"apk-file-path-can-not-be-null","errorCode":null,"errorMessage":"---APK-FILE-PATH can not be null!","messagePattern":"---APK-FILE-PATH can not be null!","errorType":"exception","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java","lineNumber":83,"sourceCode":"    private final Map<String, String> resDirMap;\n    private final Map<String, String> entryNameMap;\n    private final Map<String, Pair<Long, Long>> entrySizeMap;\n\n    public UnzipTask(JobConfig config, Map<String, String> params) {\n        super(config, params);\n        type = TASK_TYPE_UNZIP;\n        proguardClassMap = new HashMap<>();\n        resguardMap = new HashMap<>();\n        resDirMap = new HashMap<>();\n        entryNameMap = new HashMap<>();\n        entrySizeMap = new HashMap<>();\n    }\n\n    @Override\n    public void init() throws TaskInitException {\n        super.init();\n        if (Util.isNullOrNil(config.getApkPath())) {\n            throw new TaskInitException(TAG + \"---APK-FILE-PATH can not be null!\");\n        }\n        Log.i(TAG, \"inputPath:%s\", config.getApkPath());\n        inputFile = new File(config.getApkPath());\n        if (!inputFile.exists()) {\n            throw new TaskInitException(TAG + \"---'\" + config.getApkPath() + \"' is not exist!\");\n        }\n        if (Util.isNullOrNil(config.getUnzipPath())) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        Log.i(TAG, \"outputPath:%s\", config.getUnzipPath());\n        outputFile = new File(config.getUnzipPath());\n\n        if (!Util.isNullOrNil(config.getMappingFilePath())) {\n            mappingTxt = new File(config.getMappingFilePath());\n            if (!FileUtil.isLegalFile(mappingTxt)) {\n                throw new TaskInitException(TAG + \"---mapping file \" + config.getMappingFilePath() + \" is not legal!\");\n            }\n        }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java#L65-L101","documentation":"UnzipTask.init() validates the APK checker configuration before unzipping. When config.getApkPath() is null or empty (Util.isNullOrNil), it throws TaskInitException with this message. The library cannot locate the APK to analyze without an input path.","triggerScenarios":"Calling the Matrix ApkCanary task pipeline (which invokes UnzipTask.init) with an ApkCheckConfiguration whose apkPath was never set, or set to null/empty string.","commonSituations":"Forgetting to call config.setApkPath() in the gradle plugin or build script; an empty APK_PATH parameter in CI; a misconfigured extension where the apk output path is resolved after the checker runs.","solutions":["Set the APK path on the configuration before running the task: config.setApkPath(\"/path/to/app-release.apk\").","If using the matrix gradle plugin, ensure the extension's apkPath/apk output is correctly configured and points at a real APK produced by an earlier build task.","In CI, verify the environment variable or property feeding the APK path is populated at the time the check task runs (task ordering)."],"exampleFix":"// before\nApkCheckConfig config = new ApkCheckConfig();\n// after\nApkCheckConfig config = new ApkCheckConfig();\nconfig.setApkPath(\"build/outputs/apk/release/app-release.apk\");","handlingStrategy":"validation","validationCode":"if (config == null || config.getApkPath() == null || config.getApkPath().isEmpty()) {\n    throw new IllegalArgumentException(\"apkPath must be set before running ApkCanary\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    logger.error(\"ApkCanary misconfigured: \" + e.getMessage());\n    throw new GradleException(\"Set apkPath in the matrix extension\", e);\n}","preventionTips":["Always set apkPath in a shared build-script helper so it is never omitted.","Wire the check task to depend on assembleRelease so the APK path is known and populated.","Assert configuration completeness in a unit test for your build logic."],"tags":["apk-canary","configuration","missing-path","init-validation"],"backgroundTag":"missing-required-config-field","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"}