Tencent/matrix · error · GradleScriptException

Debugging APK not exist

Error message

Debugging APK not exist: ${debugApk}

What it means

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.

Solutions

  1. Build the debug APK first (./gradlew assembleDebug) so the path exists
  2. Correct the apk= path in the properties file to point at the actual APK location
  3. Use a root-project-relative path that is stable across machines

Example fix

// before
apk=/Users/oldmachine/out/app-debug.apk
// after
apk=app/build/outputs/apk/debug/app-debug.apk
Defensive patterns

Strategy: validation

Validate before calling

def apk = rootProject.file(prop.getProperty('apk'))
assert apk.exists() : 'Build assembleDebug first: ' + apk

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/76f93570f1d55149. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/gradle/WeChatDebugStub2.gradle:40

File manifestFile = file('AndroidManifest.xml')
File propFile = file('debug.properties')
File debugStubPropFile = rootProject.file('debug-stub.properties')

def minSdk
def targetSdk

// Load APK, keystore path from properties file.
if (!debugStubPropFile.exists()) {
    throw new GradleScriptException("Cannot find ${debugStubPropFile}")
} else {
    def prop = new Properties()
    debugStubPropFile.withInputStream { prop.load(it) }

    def apkPath = prop.getProperty('apk', null)
    if (apkPath) {
        debugApk = rootProject.file(apkPath)
        if (!debugApk.exists()) {
            throw new GradleScriptException("Debugging APK not exist: ${debugApk}")
        }
    } else throw new GradleScriptException("'apk' property not defined in ${debugStubPropFile}")

    def modules = prop.getProperty('modules', '').trim()
    if (modules) {
        debugModules.addAll modules.split(/\s*,\s*/)
    }

    def keystorePath = prop.getProperty('keystore', null)
    keystoreFile = keystorePath ? rootProject.file(keystorePath) :
            new File("${System.getProperty('user.home')}/.android/debug.keystore")
}

if (Math.min(manifestFile.lastModified(), propFile.lastModified()) <
        Math.max(debugApk.lastModified(), debugStubPropFile.lastModified())) {
    // Find ABIs to be installed
    def zf = new ZipFile(debugApk)
    zf.entries().each {

View on GitHub (pinned to 3b8293bd65)