Tencent/matrix · error · GradleException

need sign apk but signingConfig not found!

Error message

need sign apk but signingConfig not found!

What it means

When signing is required (`needSign = true`), the task needs both the apksigner tool and the corresponding `SigningConfig` from the Android build (key store, alias, passwords) to pass to apksigner. This error is thrown when apksigner is configured but the signingConfig parameter is null, meaning the build variant has no signing configuration to use.

Solutions

  1. Define a `signingConfigs { ... }` block in the app module and assign it to the buildType: `buildTypes { release { signingConfig signingConfigs.release } }`.
  2. Ensure the variant Matrix processes actually references that signingConfig (check `android.signingConfigs` and the variant's config).
  3. Set `needSign = false` in the matrix extension if you sign the APK manually afterwards.

Example fix

// before
android {
  buildTypes { release { minifyEnabled true } } // no signingConfig
}

// after
android {
  signingConfigs { release { storeFile file("keystore.jks"); storePassword "..."; keyAlias "..."; keyPassword "..." } }
  buildTypes { release { signingConfig signingConfigs.release } }
}
Defensive patterns

Strategy: validation

Validate before calling

android {
  signingConfigs { release { storeFile file('keystore.jks'); storePassword '...'; keyAlias '...'; keyPassword '...' } }
  buildTypes { release { signingConfig signingConfigs.release } }
}
assert android.buildTypes.release.signingConfig != null : 'release signingConfig required for matrix needSign'

Try / catch

try { ... } catch (GradleException e) { if (e.message.contains('signingConfig not found')) { logger.error('Assign signingConfig to the buildType') } throw e }

Prevention

When it happens

Trigger: `needSign = true` with a valid `apksigner` path, but the resolved variant's `signingConfig` is null — i.e. the app module has no `signingConfig` assigned to the buildType being built.

Common situations: Building a release variant that has no `signingConfig signingConfigs.release` line; using the debug buildType without a signingConfig; typos in the signingConfigs block so the config is never attached.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


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

Appendix: source

Thrown at matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/task/RemoveUnusedResourcesTask.kt:132

                resourceName = "R.$typeName.$resName"
            }
        }
        return resourceName
    }

    private fun removeUnusedResources(
            originalApk: String,
            rTxtFile: String,
            signingConfig: SigningConfig?) {

        // Check configurations
        if (needSign) {
            if (Util.isNullOrNil(apksigner)) {
                throw GradleException("need sign apk but apksigner not found!");
            } else if (!File(apksigner).exists()) {
                throw GradleException("need sign apk but apksigner $apksigner was not exist!");
            } else if (signingConfig == null) {
                throw GradleException("need sign apk but signingConfig not found!");
            }
        }

        var zipOutputStream: ZipOutputStream? = null

        try {
            try {
                val inputFile = File(originalApk)

                for (res in ignoreRes) {
                    ignoreResources.add(Util.globToRegexp(res))
                }

                val iterator = unusedResources.iterator()
                while (iterator.hasNext()) {
                    val res = iterator.next()
                    if (ignoreResource(res)) {
                        iterator.remove()

View on GitHub (pinned to 3b8293bd65)