Tencent/matrix · error · GradleScriptException
'apk' property not defined in
Error message
'apk' property not defined in ${debugStubPropFile} What it means
Thrown from WeChatDebugStub2.gradle when debug-stub.properties exists but its 'apk' property is absent (or null). The debug-stub setup cannot proceed without knowing which APK to use, so the script throws GradleScriptException during configuration, telling the developer to define the 'apk' entry in the properties file.
Solutions
- Add the line apk=<path-to-debug-apk> to the properties file
- Fix the key spelling to exactly 'apk'
- Validate the properties file contents before running the debug stub task
Example fix
// before # modules=app (no apk key) // after apk=app/build/outputs/apk/debug/app-debug.apk modules=app
Defensive patterns
Strategy: validation
Validate before calling
def prop = new Properties(); prop.load(file('debug-stub.properties').newInputStream())
assert prop.getProperty('apk') != null : 'apk key missing' Prevention
- Keep a canonical template with apk= and modules= keys
- Spell keys exactly as the script reads them
- Lint properties files in CI
When it happens
Trigger: debugStubPropFile exists but contains no apk= line, or the key is misspelled/whitespace-mangled so getProperty('apk') returns null.
Common situations: Hand-editing the properties file and dropping the apk entry; template file with placeholders never filled in; using 'APK=' or wrong casing.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Cannot find
- This plugin must be applied after "com.android.library"…
- Debugging APK not exist
- [-] Either or should be applied when use this script.
- ---jobConfig can not be null!
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/cf2520382469af10.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/gradle/WeChatDebugStub2.gradle:42
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 {
def m = (it.name =~ /^lib\/([\w-]+)\//)
if (m) installAbis << m.group(1)View on GitHub (pinned to 3b8293bd65)