apache/cordova-android · error · GradleException
The defined Google Services plugin version (${cordovaConfig.
Error message
The defined Google Services plugin version (${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}) does not appear to be a valid version. What it means
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.)
Source
Thrown at templates/project/app/build.gradle:54
if(!cdvHelpers.isVersionValid(cordovaConfig.KOTLIN_VERSION)) {
throw new GradleException("The defined Kotlin version (${cordovaConfig.KOTLIN_VERSION}) does not appear to be a valid version.")
}
}
apply from: 'repositories.gradle'
repositories repos
dependencies {
classpath "com.android.tools.build:gradle:${cordovaConfig.AGP_VERSION}"
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${cordovaConfig.KOTLIN_VERSION}"
}
if(cordovaConfig.IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED) {
// Checks if the kotlin version format is valid.
if(!cdvHelpers.isVersionValid(cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION)) {
throw new GradleException("The defined Google Services plugin version (${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}) does not appear to be a valid version.")
}
// Create the Google Services classpath and set it.
String gradlePluginGoogleServicesClassPath = "com.google.gms:google-services:${cordovaConfig.GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION}"
println "Adding classpath: ${gradlePluginGoogleServicesClassPath}"
classpath gradlePluginGoogleServicesClassPath
}
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
def hasRepositoriesGradle = file('repositories.gradle').exists()
if (hasRepositoriesGradle) {
apply from: 'repositories.gradle'
} else {
apply from: "${project.rootDir}/repositories.gradle"
}View on GitHub (pinned to 7c1e190064)
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.
Example fix
// before — platforms/android/cdv-gradle-config.json "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.-firebase", // after "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.4.0",
Defensive patterns
Strategy: validation
Validate before calling
# Validate the google-services plugin version string before invoking gradle
V=$(node -pe "JSON.parse(require('fs').readFileSync('platforms/android/cdv-gradle-config.json','utf8')).GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION")
case "$V" in
[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION '$V' is not a valid version (expected e.g. 4.4.0)"; exit 1 ;;
esac Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The defined Kotlin version (${cordovaConfig.KOTLIN_VERSION})
- No usable Android build tools found. Highest ${minBuildTools
- Malformed BoM platform: ${p}
- Unsupported system library (does not work with gradle): ${p}
- ${filePath}: Missing key required "${key}"
AI-assisted analysis of apache/cordova-android@7c1e190064 (2026-08-22).
Data as JSON: /api/errors/283f89455aabc2e7.
Report an issue: GitHub.