{"record":{"id":"283f89455aabc2e7","repo":"apache/cordova-android","slug":"the-defined-google-services-plugin-version-cord","errorCode":null,"errorMessage":"The defined Google Services plugin version (${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}) does not appear to be a valid version.","messagePattern":"The defined Google Services plugin version \\((.+?)\\) does not appear to be a valid version\\.","errorType":"validation","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"templates/project/app/build.gradle","lineNumber":54,"sourceCode":"        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            }\n\n            // Create the Google Services classpath and set it.\n            String gradlePluginGoogleServicesClassPath = \"com.google.gms:google-services:${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}\"\n            println \"Adding classpath: ${gradlePluginGoogleServicesClassPath}\"\n            classpath gradlePluginGoogleServicesClassPath\n        }\n    }\n}\n\n// Allow plugins to declare Maven dependencies via build-extras.gradle.\nallprojects {\n    def hasRepositoriesGradle = file('repositories.gradle').exists()\n    if (hasRepositoriesGradle) {\n        apply from: 'repositories.gradle'\n    } else {\n        apply from: \"${project.rootDir}/repositories.gradle\"\n    }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/cordova-android/blob/7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3/templates/project/app/build.gradle#L36-L72","documentation":"Same isVersionValid gate as the Kotlin check, but applied to GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION, and only when IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED is true (typically flipped on by a google-services-oriented plugin). The version string that ends up in cdv-gradle-config.json must parse as a real version or the buildscript throws before repositories are even resolved. (The comment above the check still says 'kotlin' — it is in fact validating the google-services plugin version.)","triggerScenarios":"A google-services/Firebase plugin writes a placeholder or malformed version into cdv-gradle-config.json (e.g. \"4.3.\", \"DEFAULT\", empty, or a range/variable); the plugin install that was supposed to set the version was interrupted; hand-editing GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION to a non-semver string.","commonSituations":"Installing plugins like cordova-plugin-firebasex or cordova-support-google-services whose gradle hooks manage this key; mixing plugin versions that expect different cordova-android templates; CI caches carrying a stale cdv-gradle-config.json.","solutions":["Set GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION in platforms/android/cdv-gradle-config.json to a valid release such as \"4.4.0\".","Update or reconfigure the plugin that manages google-services (often via its plugin.xml / install variable) so it writes a valid version itself.","If google-services is not actually required, remove the plugin and/or set IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED to false."],"exampleFix":"// before — platforms/android/cdv-gradle-config.json\n\"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION\": \"4.3.-firebase\",\n\n// after\n\"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION\": \"4.4.0\",","handlingStrategy":"validation","validationCode":"# Validate the google-services plugin version string before invoking gradle\nV=$(node -pe \"JSON.parse(require('fs').readFileSync('platforms/android/cdv-gradle-config.json','utf8')).GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION\")\ncase \"$V\" in\n  [0-9]*.[0-9]*.[0-9]*) ;;\n  *) echo \"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION '$V' is not a valid version (expected e.g. 4.4.0)\"; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Let the google-services/Firebase plugin manage its version key; pin plugin versions rather than hand-editing the config json.","Validate every *VERSION key in cdv-gradle-config.json in a pre-build check.","Keep google-services plugin and Firebase SDK versions in sync per the plugin's documented matrix."],"tags":["google-services","firebase","gradle","version","config-json"],"backgroundTag":"invalid-version-string","analyzedSha":"7c1e190064e349ffa4bbc6ac37b77cd773e4dbd3","analyzedAt":"2026-08-22T04:57:58.868Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}