{"record":{"id":"5d5ccb7f762f0698","repo":"apache/cordova-android","slug":"the-defined-kotlin-version-cordovaconfig-kotlin","errorCode":null,"errorMessage":"The defined Kotlin version (${cordovaConfig.KOTLIN_VERSION}) does not appear to be a valid version.","messagePattern":"The defined Kotlin version \\((.+?)\\) does not appear to be a valid version\\.","errorType":"validation","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"templates/project/app/build.gradle","lineNumber":37,"sourceCode":"\napply plugin: 'com.android.application'\n\nif (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {\n    apply plugin: 'kotlin-android'\n\n    if(!cdvHelpers.isVersionGreaterThanEqual(cordovaConfig.KOTLIN_VERSION, '1.8.0')) {\n        println \"Kotlin version < 1.8.0 detected. Applying kotlin-android-extensions plugin.\"\n        apply plugin: 'kotlin-android-extensions'\n    }\n}\n\nbuildscript {\n    apply from: '../CordovaLib/cordova.gradle'\n\n    // Checks if the kotlin version format is valid.\n    if(cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {\n        if(!cdvHelpers.isVersionValid(cordovaConfig.KOTLIN_VERSION)) {\n            throw new GradleException(\"The defined Kotlin version (${cordovaConfig.KOTLIN_VERSION}) does not appear to be a valid version.\")\n        }\n    }\n\n    apply from: 'repositories.gradle'\n    repositories repos\n\n    dependencies {\n        classpath \"com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}\"\n\n        if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {\n            classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:${cordovaConfig.KOTLIN_VERSION}\"\n        }\n\n        if(cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {\n            // Checks if the kotlin version format is valid.\n            if(!cdvHelpers.isVersionValid(cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION)) {\n                throw new GradleException(\"The defined Google Services plugin version (${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}) does not appear to be a valid version.\")\n            }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/templates/project/app/build.gradle#L19-L55","documentation":"In the generated app template's buildscript block, when Kotlin is enabled (IS_GRADLE_PLUGIN_KOTLIN_ENABLED), KOTLIN_VERSION is validated with cdvHelpers.isVersionValid — implemented in cordova.gradle as !(new Version(v)).isEqual('0.0.0'), where 0.0.0 is the versioncompare library's sentinel for an unparseable string. A false result means the configured Kotlin version is not a parseable semantic version. The value comes from cdv-gradle-config.json (or CordovaLib's cdv-gradle-config-defaults.json) and is frequently written or adjusted by plugins.","triggerScenarios":"KOTLIN_VERSION in cdv-gradle-config.json is an empty string, a variable placeholder like ${kotlin_version}, 'latest', '1.9+', or any malformed semver; a plugin that customizes Kotlin settings wrote a bad value; the config json was hand-edited or left half-written by an interrupted plugin install.","commonSituations":"Adding Kotlin-heavy plugins (e.g. Firebase-flavored plugins) that rewrite gradle config; manually editing platforms/android/cdv-gradle-config.json; config drift after cordova platform rm/add cycles; plugin versions incompatible with the current cordova-android template.","solutions":["Open platforms/android/cdv-gradle-config.json and set KOTLIN_VERSION to a full release semver, e.g. \"1.9.24\".","Identify which plugin rewrites that key and fix/update the plugin (often via its plugin variable) instead of fighting the generated file.","If Kotlin is not actually needed, set IS_GRADLE_PLUGIN_KOTLIN_ENABLED to false — the validation is skipped entirely.","Reset a sane baseline with cordova platform rm android && cordova platform add android, then re-apply plugin configuration in a controlled way."],"exampleFix":"// before — platforms/android/cdv-gradle-config.json\n\"KOTLIN_VERSION\": \"${kotlin_version}\",\n\n// after\n\"KOTLIN_VERSION\": \"1.9.24\",","handlingStrategy":"validation","validationCode":"# Validate the Kotlin version string before invoking gradle\nV=$(node -pe \"JSON.parse(require('fs').readFileSync('platforms/android/cdv-gradle-config.json','utf8')).KOTLIN_VERSION\")\ncase \"$V\" in\n  [0-9]*.[0-9]*.[0-9]*) ;;\n  *) echo \"KOTLIN_VERSION '$V' is not a valid version (expected e.g. 1.9.24)\"; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat cdv-gradle-config.json as generated output — change Kotlin settings through the plugin or build-extras that owns them, not by hand.","Add a before_prepare hook or CI pre-step that validates all *VERSION keys parse as semver.","After adding/removing Kotlin-dependent plugins, diff cdv-gradle-config.json to catch half-written values."],"tags":["kotlin","gradle","version","config-json","cordova"],"backgroundTag":"invalid-version-string","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}