{"record":{"id":"6abcadd9f245212e","repo":"Tencent/matrix","slug":"publishing-android-library-require-release-varia","errorCode":null,"errorMessage":"Publishing Android library require \"release\" variant","messagePattern":"Publishing Android library require \"release\" variant","errorType":"console","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/gradle/WeChatPublish.gradle","lineNumber":582,"sourceCode":"                                                    return\n                                                }\n                                                addDep(it, scope)\n                                                visitedDeps.add(it)\n                                            }\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n        } // android.libraryVariants.all\n\n        // Check whether \"release\" variant is published\n        project.afterEvaluate {\n            if (!hasReleaseVariant)\n                throw new GradleException('Publishing Android library require \"release\" variant')\n        }\n    }\n}\napply from: rootProject.file('gradle/check.gradle')","sourceCodeStart":564,"sourceCodeEnd":586,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/gradle/WeChatPublish.gradle#L564-L586","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the module has a 'release' buildType (restore default: buildTypes { release { minifyEnabled false } })","Check buildTypes/flavor configuration hasn't renamed or removed the release variant","Only apply WeChatPublish.gradle to modules that build a release variant; debug-only modules should use a different publish path"],"exampleFix":"// before (module build.gradle)\nandroid { buildTypes { debug {} } }\n\n// after\nandroid { buildTypes {\n    debug {}\n    release { minifyEnabled false }\n} }","handlingStrategy":"validation","validationCode":"// module build.gradle\nandroid {\n    buildTypes {\n        release { minifyEnabled false }\n    }\n}\nassert android.buildTypes.names.contains('release')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never remove or rename the default release buildType in publishable modules","Only apply WeChatPublish.gradle to modules that produce release artifacts","Add a CI check that 'assembleRelease' succeeds before publishing"],"tags":["gradle","android","publishing"],"backgroundTag":"missing-required-config","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}