Tencent/tinker · error · GradleException
Publishing Android library require "release" variant
Error message
Publishing Android library require "release" variant
What it means
Thrown from a project.afterEvaluate block in gradle/WeChatPublish.gradle (line 580) after the Android library's libraryVariants have been enumerated. The publish logic iterates project.android.libraryVariants.all and records whether a 'release' variant was seen (hasReleaseVariant); only the release variant is wired into MavenPublication/pom closures. If no variant named 'release' exists at evaluation time, publishing would silently produce nothing, so the script fails fast with this exception.
Source
Thrown at gradle/WeChatPublish.gradle:580
}
}
}
}
}
pomClosures.each { cl ->
project.publishing.publications {
"${publicationName}${cFlavorName}"(MavenPublication) {
pom cl
}
}
}
} // android.libraryVariants.all
// Check whether "release" variant is published
project.afterEvaluate {
if (!hasReleaseVariant)
throw new GradleException('Publishing Android library require "release" variant')
}
}
}
View on GitHub (pinned to 1b7ea02c23)
Solutions
- Ensure the module has a standard release buildType: android { buildTypes { release { ... } } } and that no variantFilter ignores it.
- Remove any 'setIgnore true' for release variants in your variantFilter block.
- If release was renamed, keep a release buildType and add your extra channels as product flavors or additional buildTypes instead of renaming release.
- If another plugin's afterEvaluate must create the variant first, apply that plugin before this publish script so its afterEvaluate callback registers earlier.
Example fix
// before
android {
variantFilter { variant ->
if (variant.buildType.name == 'release') variant.setIgnore(true)
}
}
// after
android {
buildTypes {
release {
minifyEnabled false
}
}
} Defensive patterns
Strategy: validation
Validate before calling
// quick check before running publish tasks
// (Groovy) confirm the library exposes a release variant
afterEvaluate {
def names = android.libraryVariants.collect { it.name }
assert names.contains('release') : "no release variant: ${names}"
} Prevention
- Keep a standard release buildType in every published library module.
- Never setIgnore(true) the release variant in variantFilter.
- Apply plugins that create/remove variants before the publish script so afterEvaluate ordering is deterministic.
When it happens
Trigger: Applying wechatPublish to a com.android.library module whose variants exclude release: (a) variantFilter/android.buildTypes removes or renames the release buildType; (b) buildTypes only defines debug; (c) a build system (e.g. some component-based or plugin frameworks like some Atlas/Robolectric-injected setups) mutates libraryVariants before afterEvaluate; (d) the release variant is created only later by another plugin's afterEvaluate, so this block runs first and still sees it missing.
Common situations: Publishing an Android library that intentionally ships only debug for local dev; renaming buildTypes (e.g. 'release' -> 'online') for channel flavors; variantFilter { setIgnore true } on release; ordering conflicts between wechatPublish's afterEvaluate and another plugin that adds or removes variants.
Related errors
- This plugin must be applied after "java" or "com.android.lib
- tinkerFlag is already set.
- tinkerLoadVerifyFlag must not be null.
- tinkerLoadVerifyFlag is already set.
- loadReporter is already set.
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/6da6448cc18b87d0.
Report an issue: GitHub.