{"record":{"id":"bdd4051142f728b9","repo":"Tencent/matrix","slug":"need-sign-apk-but-apksigner-apksigner-was-not-exi","errorCode":null,"errorMessage":"need sign apk but apksigner $apksigner was not exist!","messagePattern":"need sign apk but apksigner \\$apksigner was 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/RemoveUnusedResourcesTask.kt","lineNumber":130,"sourceCode":"                    typeName = typeName.substring(0, index)\n                }\n                resourceName = \"R.$typeName.$resName\"\n            }\n        }\n        return resourceName\n    }\n\n    private fun removeUnusedResources(\n            originalApk: String,\n            rTxtFile: String,\n            signingConfig: SigningConfig?) {\n\n        // Check configurations\n        if (needSign) {\n            if (Util.isNullOrNil(apksigner)) {\n                throw GradleException(\"need sign apk but apksigner not found!\");\n            } else if (!File(apksigner).exists()) {\n                throw GradleException(\"need sign apk but apksigner $apksigner was not exist!\");\n            } else if (signingConfig == null) {\n                throw GradleException(\"need sign apk but signingConfig not found!\");\n            }\n        }\n\n        var zipOutputStream: ZipOutputStream? = null\n\n        try {\n            try {\n                val inputFile = File(originalApk)\n\n                for (res in ignoreRes) {\n                    ignoreResources.add(Util.globToRegexp(res))\n                }\n\n                val iterator = unusedResources.iterator()\n                while (iterator.hasNext()) {\n                    val res = iterator.next()","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/task/RemoveUnusedResourcesTask.kt#L112-L148","documentation":"This variant of the signing configuration check fires when an `apksigner` path WAS provided but the file does not exist on disk. The task verifies `File(apksigner).exists()` before signing the shrunk APK and fails fast with the configured path included in the message.","triggerScenarios":"`needSign = true`, `apksigner` is a non-empty string, but `File(apksigner).exists()` returns false when `removeUnusedResources` executes.","commonSituations":"Hard-coded path from another machine or CI image; SDK upgraded and the old build-tools directory was deleted; relative path resolved against a different working directory; typo in path or missing executable extension on Windows.","solutions":["Point `apksigner` at an existing build-tools binary on the current machine: `$ANDROID_HOME/build-tools/<version>/apksigner` (apksigner.bat on Windows).","Run `ls` on the configured path to confirm it exists and is executable; update the config.","Install the required build-tools version via the Android SDK manager if it is missing.","Or set `needSign = false` if re-signing is not needed."],"exampleFix":"// before\napksigner = \"/Users/alice/Library/Android/sdk/build-tools/28.0.3/apksigner\" // deleted by SDK upgrade\n\n// after (check existing version first)\napksigner = \"/Users/alice/Library/Android/sdk/build-tools/34.0.0/apksigner\"","handlingStrategy":"validation","validationCode":"def apksigner = new File(\"${System.getenv('ANDROID_HOME')}/build-tools/34.0.0/apksigner\")\nassert apksigner.exists() : \"apksigner missing at ${apksigner}\"","typeGuard":"def apksignerExists = { String p -> p != null && new File(p).exists() }","tryCatchPattern":"try { ... } catch (GradleException e) { if (e.message.contains('was not exist')) { logger.error('Fix apksigner path: ' + e.message) } throw e }","preventionTips":["Resolve apksigner path dynamically from the SDK location and an existing build-tools version.","Re-verify the path after SDK/build-tools upgrades.","Check path exists on every CI agent, not just local machines."],"tags":["gradle","android","signing","file-not-found"],"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"}