Tencent/matrix · error · GradleException

Need signing apk but signingConfig is not specified!

Error message

Need signing apk but signingConfig is not specified!

What it means

Thrown by RemoveUnusedResourcesTaskV2.parametersInvalidation when signing is enabled, apksigner exists, but the variant's signingConfig is null (AgpCompat.getSigningConfig(variant) == null). apksigner needs a keystore/alias/password configuration to re-sign, so the task aborts.

Solutions

  1. Add a signingConfig to the variant: android { signingConfigs { release { ... } } buildTypes { release { signingConfig signingConfigs.release } } }.
  2. Or run the task only on variants that have a signingConfig.
  3. Or set useApkSign = false if the APK is signed in a later pipeline step.

Example fix

// before
android {
  buildTypes {
    release {
      minifyEnabled true // no signingConfig
    }
  }
}
// after
android {
  signingConfigs {
    release {
      storeFile file("release.keystore")
      storePassword "..."
      keyAlias "..."
      keyPassword "..."
    }
  }
  buildTypes {
    release {
      signingConfig signingConfigs.release
    }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

android.applicationVariants.all { v ->
  if (v.buildType.signingConfig == null) {
    logger.warn("Variant ${v.name} has no signingConfig; removeUnusedResources with useApkSign will fail")
  }
}

Prevention

When it happens

Trigger: Running removeUnusedResources on a variant (commonly debug or a custom variant) whose buildType has no signingConfig set, while useApkSign=true in the Matrix config.

Common situations: Debug variants without a custom signing config; release builds built before adding signingConfig blocks; flavors that override buildTypes and drop signingConfig.

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/856ca04b5d4e80da. Report an issue: GitHub.

Appendix: source

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

        }

        // Validate path of Zipalign tool
        if (isZipAlignEnabled) {
            if (Util.isNullOrNil(pathOfZipAlign)) {
                throw GradleException("Need zip align apk but the path of zipalign is not specified!")
            } else if (!File(pathOfZipAlign).exists()) {
                throw GradleException("Need zipalign apk but $pathOfZipAlign is not exist!")
            }
        }

        // Validate path of signing
        if (isSigningEnabled) {
            if (Util.isNullOrNil(pathOfApkSigner)) {
                throw GradleException("Need signing apk but the path of apksigner is not specified!")
            } else if (!File(pathOfApkSigner).exists()) {
                throw GradleException("Need signing apk but $pathOfApkSigner is not exist!")
            } else if (AgpCompat.getSigningConfig(variant) == null) {
                throw GradleException("Need signing apk but signingConfig is not specified!")
            }
        }
    }

    private fun calculateResources(
            setOfUnusedResources: Set<String>,
            mapOfDuplicatedResources: Map<String, MutableSet<String>>,
            mapOfResources: MutableMap<String, Int>,
            resultOfResourcesGonnaRemoved: MutableMap<String, Int>,
            resultOfDuplicatesReplacements: MutableMap<String, String>,
            resultOfObfuscatedNames: MutableMap<String, String>
    ) {

        // Prepare unused resources
        val regexpRules = HashSet<String>()
        for (res in rulesOfIgnore) {
            regexpRules.add(Util.globToRegexp(res))
        }

View on GitHub (pinned to 3b8293bd65)