{"record":{"id":"7f4ca69f41e2c7dd","repo":"Tencent/matrix","slug":"apksigner-returned-with-status-ret","errorCode":null,"errorMessage":"apksigner returned with status: $ret","messagePattern":"apksigner returned with status: \\$ret","errorType":"console","errorClass":"GradleScriptException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/gradle/WeChatDebugStub2.gradle","lineNumber":203,"sourceCode":"                    if (Files.isDirectory(it)) {\n                        Files.createDirectories(outPath)\n                    } else {\n                        Files.copy(it, outPath, StandardCopyOption.REPLACE_EXISTING)\n                    }\n                }\n            } finally {\n                outFS?.close()\n                inFS?.close()\n            }\n\n            // Sign the resulting APK\n            def proc = [\"${sdkDir}/build-tools/${buildToolsVersion}/apksigner\", 'sign', '--ks',\n                        keystoreFile.absolutePath, '--ks-pass', 'pass:android', \"${tmpFile}\"]\n                    .execute(null, file('.'))\n            proc.consumeProcessOutput(System.out, System.err)\n            def ret = proc.waitFor()\n            if (ret != 0)\n                throw new GradleScriptException(\"apksigner returned with status: $ret\")\n\n            // Move the resulting APK to replace the original output\n            Files.move(tmpFile.toPath(), outputApk.toPath(), StandardCopyOption.REPLACE_EXISTING)\n        } catch (e) {\n            tmpFile.delete()\n            throw e\n        }\n    }\n}\n","sourceCodeStart":185,"sourceCodeEnd":213,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/gradle/WeChatDebugStub2.gradle#L185-L213","documentation":"The script signs the patched temporary APK by invoking apksigner from the Android SDK build-tools and throws GradleScriptException with the exit code if apksigner exits non-zero, meaning signing failed.","triggerScenarios":"apksigner exits non-zero due to a bad/incompatible keystore, wrong keystore password, missing build-tools version, corrupted patched APK, or apksigner not found at the expected sdkDir path (shell reports non-zero).","commonSituations":"Missing or mismatched build-tools installation; using the default 'android' debug keystore password with a custom keystore; JAVA/apksigner version incompatibilities (e.g. v1-only signatures vs minSdk); disk-full during tmp APK write.","solutions":["Verify $ANDROID_HOME/build-tools/<buildToolsVersion>/apksigner exists and is executable","Run the same apksigner command manually to see the real error output","Ensure the keystore exists and its password matches the hardcoded pass:android or update the script","Install/align the required build-tools version via sdkmanager"],"exampleFix":"// before\n// buildToolsVersion from project, but not installed\n// after\nsdkmanager \"build-tools;30.0.3\" // match buildToolsVersion in script","handlingStrategy":"validation","validationCode":"def apksigner = file(\"${sdkDir}/build-tools/${buildToolsVersion}/apksigner\")\nassert apksigner.exists() : \"Install build-tools ${buildToolsVersion}\"\nassert keystoreFile.exists() : 'Keystore missing'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the exact build-tools version the script expects","Confirm keystore path and password (default pass:android)","Reproduce the apksigner command manually on failure","Log apksigner stdout/stderr before throwing"],"tags":["gradle","apksigner","signing","android","build-tools"],"backgroundTag":"command-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"}