Tencent/matrix · error · GradleException

Publishing Android library require "release" variant

Error message

Publishing Android library require "release" variant

What it means

When configuring publications, the script iterates android.libraryVariants and records whether a 'release' variant exists/was selected. At project.afterEvaluate, if hasReleaseVariant is still false, publishing an Android library cannot proceed (the plugin only publishes release artifacts), so it throws a GradleException.

Solutions

  1. Ensure the module has a 'release' buildType (restore default: buildTypes { release { minifyEnabled false } })
  2. Check buildTypes/flavor configuration hasn't renamed or removed the release variant
  3. Only apply WeChatPublish.gradle to modules that build a release variant; debug-only modules should use a different publish path

Example fix

// before (module build.gradle)
android { buildTypes { debug {} } }

// after
android { buildTypes {
    debug {}
    release { minifyEnabled false }
} }
Defensive patterns

Strategy: validation

Validate before calling

// module build.gradle
android {
    buildTypes {
        release { minifyEnabled false }
    }
}
assert android.buildTypes.names.contains('release')

Prevention

When it happens

Trigger: Applying WeChatPublish.gradle to an Android library module that has release builds disabled (e.g. android.buildTypes with release missing or 'matchingFallbacks' issues, AOSP-style modules where release variant is absent), or publishing a module where only debug variants are configured.

Common situations: Modules created without the default release build type, CI variants configuration that removed the release buildType, or applying the publish script to a debug-only flavor setup.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/6abcadd9f245212e. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/gradle/WeChatPublish.gradle:582

                                                    return
                                                }
                                                addDep(it, scope)
                                                visitedDeps.add(it)
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // android.libraryVariants.all

        // Check whether "release" variant is published
        project.afterEvaluate {
            if (!hasReleaseVariant)
                throw new GradleException('Publishing Android library require "release" variant')
        }
    }
}
apply from: rootProject.file('gradle/check.gradle')

View on GitHub (pinned to 3b8293bd65)