flutter build_error ai_generated true

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

Also available as: JSON · Markdown · 中文
88%Fix Rate
87%Confidence
1Evidence
2025-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Flutter 3.13.0 active
Flutter 3.19.0 active
Flutter 3.22.0 active

Root Cause

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

中文

密钥库文件包含一个别名与`build.gradle`中签名配置指定的别名不匹配的密钥,通常是由于使用了不同的密钥库或重新生成了密钥。

Official Documentation

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

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

  2. 90% fail

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

  3. 95% fail

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