Tencent/tinker · error · GradleException
Invalid version: ${fullVersion}
Error message
Invalid version: ${fullVersion} What it means
Thrown by the private checkVersion() in gradle/WeChatPublish.gradle (line 172) during afterEvaluate-time publish configuration. It validates project.ext.fullVersion against the regex /\d+\.\d+(?:\.\d+)?(?:\.\d+)?(?:\.\d+)?(?:-[\w-]+)?/ — i.e. at least 'major.minor' (up to three extra numeric segments) plus an optional '-suffix'. When the version does not match and isSnapshot is false, it throws; when isSnapshot is true it only prints the message to stderr and continues. Note the regex is an unanchored Groovy ==~ match, so the whole string must match, meaning leading 'v', '+', spaces, or 'SNAPSHOT' instead of a '-suffix' form all fail.
Source
Thrown at gradle/WeChatPublish.gradle:172
checkVersion()
if (!usedDefaultIsSnapshot) {
System.err.println 'isSnapshot should be avoided in build scripts.'
}
if (isSnapshot) {
// Bintray does not allow SNAPSHOT publish
publishToBintray = false
}
project.ext.fullVersion = fullVersion
}
private void checkVersion() {
if (!(fullVersion ==~ /\d+\.\d+(?:\.\d+)?(?:\.\d+)?(?:\.\d+)?(?:-[\w-]+)?/)) {
def message = "Invalid version: ${fullVersion}"
if (!isSnapshot)
throw new GradleException(message)
System.err.println(message)
}
}
final protected String getPublicationName() {
String result = ""
artifactId.split("[-_]").each { result += it.capitalize() }
return uncapitalize(result)
}
protected void mountAdditionalLogic(project) {}
protected void emitPublicationDSL(Project project) {}
private void emitSigningConfig(Project project) {
project.ext['signing.keyId'] = project.findProperty("signingKeyId")
project.ext['signing.password'] = project.findProperty("signingPassword")
project.ext['signing.secretKeyRingFile'] = project.findProperty("signingSecretKeyRingFile")View on GitHub (pinned to 1b7ea02c23)
Solutions
- Set a version matching the pattern: major.minor with up to three optional numeric segments and an optional hyphenated suffix without dots, e.g. '1.2.3' or '1.2.3-RC1'.
- Strip non-conforming decorations before assignment (e.g. remove a leading 'v' from a git tag: version = tag.substring(1)).
- If the odd version is intentional and you only need a local snapshot build, leave isSnapshot = true (default) — the message is printed but no exception is thrown.
- If you own the script, relax/anchor the regex, e.g. /\d+(?:\.\d+){1,3}(?:-[\w.\-]+)?/.
Example fix
// before
wechatPublish {
version = 'v1.0-beta.2'
isSnapshot = false
}
// after
wechatPublish {
version = '1.0.0-beta-2'
isSnapshot = false
} Defensive patterns
Strategy: validation
Validate before calling
// before assigning, validate against the same pattern the script uses def VERSION_RE = ~/\d+\.\d+(?:\.\d+)?(?:\.\d+)?(?:\.\d+)?(?:-[\w-]+)?/ String v = /* your version source */ '1.2.3-RC1' assert v ==~ VERSION_RE : "version '$v' will be rejected by WeChatPublish.checkVersion()"
Try / catch
try { /* publish task */ } catch (GradleException e) { if (e.message?.startsWith('Invalid version:')) { /* fix version, re-run */ } else throw e } Prevention
- Use plain 'major.minor[.patch]' with optional hyphen suffixes (no dots in the suffix, no leading 'v').
- Validate the version string in CI before invoking publish tasks.
- Remember isSnapshot=true only downgrades the throw to an stderr warning; do not rely on it to mask a bad release version.
When it happens
Trigger: Calling the publish task (or any task that evaluates wechatPublish { version = ... }) with a release (isSnapshot=false) version such as '1.0.SNAPSHOT', 'v1.0.0', '1.0-beta.2' (dot in suffix — [\w-]+ does not allow dots), '1.0 3', or an empty/unspecified version string that is not covered by the 'unspecified' -> '0.1' default. With isSnapshot=true the same input only produces the stderr warning and never throws.
Common situations: Migrating a Maven/Bintray version scheme ('1.0.0-SNAPSHOT' works only as suffix '-SNAPSHOT'? — actually '-SNAPSHOT' matches [\w-]+, but '1.0.0.Final' or '1.0-beta.1' does not); setting version from a git tag like 'v2.1'; copying a semver prerelease with dots; forgetting to set version so a non-numeric placeholder leaks through.
Related errors
- Please specify '$name' option in gradle project properties.
- This plugin must be applied after "java" or "com.android.lib
- Publishing Android library require "release" variant
- Unexpected header: 0x${headerSize}
- Unexpected endian tag: 0x${endianTag}
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/858bcaeb1db80631.
Report an issue: GitHub.