{"record":{"id":"4cf6e5679a46a5a4","repo":"Tencent/matrix","slug":"need-zipalign-apk-but-pathofzipalign-is-not-exist","errorCode":null,"errorMessage":"Need zipalign apk but $pathOfZipAlign is not exist!","messagePattern":"Need zipalign apk but \\$pathOfZipAlign is not exist!","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/task/RemoveUnusedResourcesTaskV2.kt","lineNumber":485,"sourceCode":"    }\n\n    private fun parametersInvalidation() {\n\n        // Validate path of ApkChecker tool\n        if (!Util.isNullOrNil(pathOfApkChecker)) {\n            if (!File(pathOfApkChecker).exists()) {\n                throw GradleException(\"the path of Matrix-ApkChecker $pathOfApkChecker is not exist!\")\n            }\n        } else {\n            throw GradleException(\"the path of Matrix-ApkChecker not found!\")\n        }\n\n        // Validate path of Zipalign tool\n        if (isZipAlignEnabled) {\n            if (Util.isNullOrNil(pathOfZipAlign)) {\n                throw GradleException(\"Need zip align apk but the path of zipalign is not specified!\")\n            } else if (!File(pathOfZipAlign).exists()) {\n                throw GradleException(\"Need zipalign apk but $pathOfZipAlign is not exist!\")\n            }\n        }\n\n        // Validate path of signing\n        if (isSigningEnabled) {\n            if (Util.isNullOrNil(pathOfApkSigner)) {\n                throw GradleException(\"Need signing apk but the path of apksigner is not specified!\")\n            } else if (!File(pathOfApkSigner).exists()) {\n                throw GradleException(\"Need signing apk but $pathOfApkSigner is not exist!\")\n            } else if (AgpCompat.getSigningConfig(variant) == null) {\n                throw GradleException(\"Need signing apk but signingConfig is not specified!\")\n            }\n        }\n    }\n\n    private fun calculateResources(\n            setOfUnusedResources: Set<String>,\n            mapOfDuplicatedResources: Map<String, MutableSet<String>>,","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/task/RemoveUnusedResourcesTaskV2.kt#L467-L503","documentation":"Thrown by RemoveUnusedResourcesTaskV2.parametersInvalidation when zip align is enabled and pathOfZipAlign is set, but the file at that path does not exist. The task refuses to run rather than failing later during execution of zipalign.","triggerScenarios":"Running removeUnusedResources with zipAlignEnabled=true and a non-empty zipAlignPath that points to a nonexistent file (typo, wrong SDK version directory, binary removed after SDK update).","commonSituations":"Hardcoded build-tools path after upgrading the Android SDK (e.g. build-tools/30.0.3 no longer installed); team members with different SDK versions; CI images missing specific build-tools revisions.","solutions":["Correct zipAlignPath to an existing zipalign binary: ls $ANDROID_HOME/build-tools/*/zipalign and pick the installed version.","Install the matching build-tools platform via the SDK manager so the configured path exists.","Disable zip alignment (zipAlignEnabled = false) if not needed.","Generate the path dynamically from android.sdkDirectory instead of hardcoding."],"exampleFix":"// before\nzipAlignPath = \"/opt/android-sdk/build-tools/30.0.3/zipalign\" // directory removed\n// after\nzipAlignPath = file(\"${android.sdkDirectory}/build-tools/${project.buildToolsVersion}/zipalign\").absolutePath","handlingStrategy":"validation","validationCode":"def zipalign = file(\"${android.sdkDirectory}/build-tools/${project.buildToolsVersion}/zipalign\")\nif (matrix.removeResourceConfig.zipAlignEnabled && !zipalign.exists()) {\n  throw new GradleException(\"zipalign not found at ${zipalign}; install matching build-tools\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hardcode build-tools versions in tool paths; derive from buildToolsVersion.","Pin buildToolsVersion and ensure CI installs it via sdkmanager.","Add a preflight check task that verifies all configured tool paths exist."],"tags":["gradle","android","file-not-found","build-tool"],"backgroundTag":"file-not-found","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"}