Gradle任务assembleRelease失败,退出代码1:任务':app:signReleaseBundle'执行失败 > 密钥使用的算法(RSA)与预期(EC)不同
Gradle task assembleRelease failed with exit code 1: Execution failed for task ':app:signReleaseBundle' > Key was created with a different algorithm (RSA) than expected (EC)
ID: flutter/gradle-sign-release-key-created
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Flutter 3.13.0 | active | — | — | — |
| Android Gradle Plugin 8.0 | active | — | — | — |
| Android Gradle Plugin 8.2 | active | — | — | — |
根因分析
用于发布包的签名密钥使用RSA算法创建,但Gradle配置期望EC(椭圆曲线)密钥,反之亦然,这是由于密钥类型与密钥库配置之间的不匹配。
English
The signing key used for the release bundle was created with RSA algorithm but the Gradle configuration expects an EC (Elliptic Curve) key, or vice versa, due to a mismatch between the key type and the key store configuration.
官方文档
https://developer.android.com/studio/publish/app-signing解决方案
-
Update the signing configuration in android/app/build.gradle to specify the correct key algorithm that matches the key store's key, e.g., keyAlgorithm 'RSA' or 'EC'.
-
Inspect the key store to determine the actual algorithm using keytool -list -v -keystore my-release-key.jks and then set the correct algorithm in build.gradle.
-
If using Android App Bundle, switch to using Play App Signing and upload the original key to Google Play, then use the upload key for local builds.
无效尝试
常见但无效的做法:
-
Regenerate the key with the same algorithm as expected, but keep the same alias
60% 失败
This invalidates the old key and requires re-uploading to Google Play Console; also the error persists if the configuration is not updated.
-
Delete the key store and create a new one with the correct algorithm
70% 失败
This loses existing signing credentials and may break CI/CD pipelines that rely on the old key.
-
Set keyAlgorithm to RSA in build.gradle
80% 失败
If the actual key is EC, this still fails; the algorithm must match the key, not be hardcoded.