flutter build_error ai_generated true

Gradle task assembleRelease failed with exit code 1: Execution failed for task ':app:signReleaseBundle' > Key was created with errors: Key was created with errors: Invalid keystore format

ID: flutter/signing-key-creation-error

Also available as: JSON · Markdown · 中文
85%Fix Rate
86%Confidence
1Evidence
2024-02-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Flutter 3.16+ active
Gradle 8.3+ active
Android Studio Iguana 2023.2.1+ active

Root Cause

The keystore file used for signing the release bundle is corrupted, in an unsupported format, or was created with a different Java version than the current build environment.

generic

中文

用于签署发布包的密钥库文件已损坏、格式不受支持,或使用与当前构建环境不同的 Java 版本创建。

Official Documentation

https://developer.android.com/studio/publish/app-signing

Workarounds

  1. 85% success Regenerate the keystore using Java 11 or newer: keytool -genkey -v -keystore release.keystore -alias my-key -keyalg RSA -keysize 2048 -validity 10000 -storetype JKS. Then update android/key.properties with the new file path.
    Regenerate the keystore using Java 11 or newer: keytool -genkey -v -keystore release.keystore -alias my-key -keyalg RSA -keysize 2048 -validity 10000 -storetype JKS. Then update android/key.properties with the new file path.
  2. 80% success Convert the existing keystore to PKCS12 format: keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -deststoretype pkcs12. Then reference the new file in key.properties.
    Convert the existing keystore to PKCS12 format: keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -deststoretype pkcs12. Then reference the new file in key.properties.
  3. 90% success If using Android Studio, create a new keystore via Build > Generate Signed Bundle/APK > Create new. Ensure Java version in File > Project Structure > SDK Location matches the keystore creation version.
    If using Android Studio, create a new keystore via Build > Generate Signed Bundle/APK > Create new. Ensure Java version in File > Project Structure > SDK Location matches the keystore creation version.

中文步骤

  1. 使用 Java 11 或更高版本重新生成密钥库:keytool -genkey -v -keystore release.keystore -alias my-key -keyalg RSA -keysize 2048 -validity 10000 -storetype JKS。然后更新 android/key.properties 中的文件路径。
  2. 将现有密钥库转换为 PKCS12 格式:keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -deststoretype pkcs12。然后在 key.properties 中引用新文件。
  3. 如果使用 Android Studio,通过 Build > Generate Signed Bundle/APK > Create new 创建新密钥库。确保 File > Project Structure > SDK Location 中的 Java 版本与密钥库创建版本匹配。

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Converting the keystore to PKCS12 format using keytool without specifying the correct alias often results in missing key entries and signature failures.

  2. 90% fail

    Deleting the keystore and creating a new one without backing up the original causes loss of the signing key, preventing app updates on the same package name.

  3. 80% fail

    Copying the keystore from another project without changing the key alias may cause signature conflicts with Google Play Store.