{"record":{"id":"76f93570f1d55149","repo":"Tencent/matrix","slug":"debugging-apk-not-exist-debugapk","errorCode":null,"errorMessage":"Debugging APK not exist: ${debugApk}","messagePattern":"Debugging APK not exist: (.+?)","errorType":"console","errorClass":"GradleScriptException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/gradle/WeChatDebugStub2.gradle","lineNumber":40,"sourceCode":"File manifestFile = file('AndroidManifest.xml')\nFile propFile = file('debug.properties')\nFile debugStubPropFile = rootProject.file('debug-stub.properties')\n\ndef minSdk\ndef targetSdk\n\n// Load APK, keystore path from properties file.\nif (!debugStubPropFile.exists()) {\n    throw new GradleScriptException(\"Cannot find ${debugStubPropFile}\")\n} else {\n    def prop = new Properties()\n    debugStubPropFile.withInputStream { prop.load(it) }\n\n    def apkPath = prop.getProperty('apk', null)\n    if (apkPath) {\n        debugApk = rootProject.file(apkPath)\n        if (!debugApk.exists()) {\n            throw new GradleScriptException(\"Debugging APK not exist: ${debugApk}\")\n        }\n    } else throw new GradleScriptException(\"'apk' property not defined in ${debugStubPropFile}\")\n\n    def modules = prop.getProperty('modules', '').trim()\n    if (modules) {\n        debugModules.addAll modules.split(/\\s*,\\s*/)\n    }\n\n    def keystorePath = prop.getProperty('keystore', null)\n    keystoreFile = keystorePath ? rootProject.file(keystorePath) :\n            new File(\"${System.getProperty('user.home')}/.android/debug.keystore\")\n}\n\nif (Math.min(manifestFile.lastModified(), propFile.lastModified()) <\n        Math.max(debugApk.lastModified(), debugStubPropFile.lastModified())) {\n    // Find ABIs to be installed\n    def zf = new ZipFile(debugApk)\n    zf.entries().each {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/gradle/WeChatDebugStub2.gradle#L22-L58","documentation":"Thrown from WeChatDebugStub2.gradle when the 'apk' entry in debug-stub.properties resolves to a path that does not exist. The script loads the APK for the debug-stub build (packaging the Matrix stub against a real APK), and building against a missing APK would break downstream tasks, so it fails the Gradle configuration phase with GradleScriptException.","triggerScenarios":"The properties file defines an apk=... path that points to a non-existent file: stale absolute path, typo, APK not built yet, or path not relative to the root project as expected.","commonSituations":"Running the task before assembling the debug APK; switching machines where the absolute path no longer exists; renaming build outputs (build/intermediates changes across AGP versions).","solutions":["Build the debug APK first (./gradlew assembleDebug) so the path exists","Correct the apk= path in the properties file to point at the actual APK location","Use a root-project-relative path that is stable across machines"],"exampleFix":"// before\napk=/Users/oldmachine/out/app-debug.apk\n// after\napk=app/build/outputs/apk/debug/app-debug.apk","handlingStrategy":"validation","validationCode":"def apk = rootProject.file(prop.getProperty('apk'))\nassert apk.exists() : 'Build assembleDebug first: ' + apk","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run assembleDebug before the debug-stub task","Use root-relative APK paths in properties","Check APK existence in CI before invoking the task"],"tags":["gradle","apk","file-not-found","build-script"],"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"}