{"record":{"id":"84520344c16defc2","repo":"apache/cordova-android","slug":"filepath-missing-key-required-key","errorCode":null,"errorMessage":"${filePath}: Missing key required \"${key}\"","messagePattern":"(.+?): Missing key required \"(.+?)\"","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"framework/cordova.gradle","lineNumber":26,"sourceCode":"    with the License.  You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing,\n    software distributed under the License is distributed on an\n    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n    KIND, either express or implied.  See the License for the\n    specific language governing permissions and limitations\n    under the License.\n*/\n\nimport groovy.xml.XmlParser\nimport java.util.regex.Pattern\nimport io.github.g00fy2.versioncompare.Version\n\nString doEnsureValueExists(filePath, props, key) {\n    if (props.get(key) == null) {\n        throw new GradleException(filePath + ': Missing key required \"' + key + '\"')\n    }\n    return props.get(key)\n}\n\nString doGetProjectTarget() {\n    def props = new Properties()\n    def propertiesFile = 'project.properties';\n    if(!(file(propertiesFile).exists())) {\n      propertiesFile = '../project.properties';\n    }\n    file(propertiesFile).withReader { reader ->\n        props.load(reader)\n    }\n    return doEnsureValueExists('project.properties', props, 'target')\n}\n\nBoolean isVersionValid(version) {\n    return !(new Version(version)).isEqual('0.0.0')","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/framework/cordova.gradle#L8-L44","documentation":"doEnsureValueExists is the guard Cordova's gradle scripts use whenever a Java properties file must contain a key. doGetProjectTarget requires target in project.properties (or ../project.properties); the app template's addSigningProps uses privateHelpers.ensureValueExists as the fallback for storeFile and keyAlias in signing properties files; plugin gradle scripts can call it too. When props.get(key) returns null it throws a GradleException naming the offending file and key.","triggerScenarios":"platforms/android/project.properties lost its target= line (manual edit, bad merge, partially generated platform); release-signing.properties / debug-signing.properties contains neither key.store nor storeFile (or neither key.alias nor keyAlias), so the fallback lookup fires and fails; a plugin gradle script calls privateHelpers.ensureValueExists for a key its props file does not define.","commonSituations":"Projects generated by very old cordova-android releases then upgraded in place; platform files hand-edited or cloned incompletely (platforms/ partially in git); signing properties files trimmed down during CI setup; plugins that rewrite properties files in before_build hooks.","solutions":["Open the file named in the message and add the missing key — for project.properties that is e.g. target=android-34.","For signing files, add storeFile=/abs/path/app.keystore and keyAlias=alias (or the legacy key.store / key.alias pair) to the named .properties file.","If platform files look hand-mangled, regenerate them: cordova platform rm android && cordova platform add android, then reapply only documented customizations."],"exampleFix":"# before — platforms/android/project.properties\nsdk.dir=/opt/android-sdk\n\n# after\nsdk.dir=/opt/android-sdk\ntarget=android-34","handlingStrategy":"validation","validationCode":"// Fail fast with your own message before Cordova's gradle script runs (build-extras.gradle or a prebuild task)\ndef props = new Properties()\nfile('project.properties').withReader { props.load(it) }\ndef required = ['target']\ndef missing = required.findAll { props.get(it) == null }\nif (missing) {\n    throw new GradleException('project.properties missing required keys: ' + missing.join(', '))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let the cordova CLI generate and maintain platform files; do not hand-delete keys from project.properties.","Commit a template of signing properties files (without secrets) so required keys are never accidentally dropped.","Run cordova prepare / platform rm+add after upgrading cordova-android to regenerate canonical platform files."],"tags":["gradle","properties","build-config","android"],"backgroundTag":"missing-required-config-key","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}