flutter build_error ai_generated true

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

其他格式: JSON · Markdown 中文 · English
88%修复率
87%置信度
1证据数
2025-01-20首次发现

版本兼容性

版本状态引入弃用备注
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.

generic

官方文档

https://docs.flutter.dev/deployment/android#signing-the-app

解决方案

  1. 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.
  2. If the alias is correct, ensure the keystore path and passwords are correct in `key.properties` and `build.gradle`.
  3. Recreate the keystore with the exact alias specified: `keytool -genkey -v -keystore release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias your-alias`.

无效尝试

常见但无效的做法:

  1. 80% 失败

    This invalidates the old signing key, which may cause issues with app updates on the Play Store.

  2. 90% 失败

    This will still not match the actual alias in the keystore; the alias must match exactly.

  3. 95% 失败

    This bypasses the error but uses a debug key for release, which is insecure and not allowed for Play Store upload.