Gradle任务assembleRelease失败,退出代码1:任务':app:signReleaseBundle'执行失败 > 密钥是用与所用别名不同的别名创建的
Gradle task assembleRelease failed with exit code 1: Execution failed for task ':app:signReleaseBundle' > Key was created with a different alias than the one used
ID: flutter/android-signing-key-created-with-incorrect-alias
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Flutter 3.13.0 | active | — | — | — |
| Flutter 3.19.0 | active | — | — | — |
| Flutter 3.22.0 | active | — | — | — |
根因分析
密钥库文件包含一个别名与`build.gradle`中签名配置指定的别名不匹配的密钥,通常是由于使用了不同的密钥库或重新生成了密钥。
English
The keystore file contains a key with an alias that does not match the alias specified in the signing configuration in `build.gradle`, often due to using a different keystore or regenerating keys.
官方文档
https://docs.flutter.dev/deployment/android#signing-the-app解决方案
-
List aliases in the keystore using `keytool -list -keystore your-keystore.jks -storepass your-storepass` and update the `keyAlias` in `android/app/build.gradle` to match.
-
If the alias is correct, ensure the keystore path and passwords are correct in `key.properties` and `build.gradle`.
-
Recreate the keystore with the exact alias specified: `keytool -genkey -v -keystore release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias your-alias`.
无效尝试
常见但无效的做法:
-
80% 失败
This invalidates the old signing key, which may cause issues with app updates on the Play Store.
-
90% 失败
This will still not match the actual alias in the keystore; the alias must match exactly.
-
95% 失败
This bypasses the error but uses a debug key for release, which is insecure and not allowed for Play Store upload.