# Gradle任务assembleRelease失败，退出码1：':app:signReleaseBundle'任务执行失败 > 密钥创建错误：未找到密钥库文件

- **ID:** `flutter/gradle-task-assemble-release-signature-mismatch`
- **领域:** flutter
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

build.gradle中指定的用于签署发布包的密钥库文件在给定路径下不存在。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.10 | active | — | — |
| Android Gradle Plugin 8.1 | active | — | — |
| Gradle 8.2 | active | — | — |

## 解决方案

1. ```
   Verify the keystore path in android/app/build.gradle and ensure the file exists. Example: storeFile file('../keystores/release.jks') should point to an existing file. Move the keystore to the correct location or update the path.
   ```
2. ```
   If using environment variables, check that the variable is set correctly. Run 'echo $KEYSTORE_PATH' in terminal to confirm. In build.gradle, use storeFile file(System.getenv('KEYSTORE_PATH')).
   ```
3. ```
   Generate a new keystore if the old one is lost: 'keytool -genkey -v -keystore release.jks -keyalg RSA -keysize 2048 -validity 10000 -alias release' and update build.gradle accordingly.
   ```

## 无效尝试

- **** — The keystore path is hardcoded and cleaning the build does not create the keystore file. (95% 失败率)
- **** — The error is about the file path, not the password; password changes are irrelevant. (85% 失败率)
- **** — The keystore file is not inside the build folder; it's a separate file that must exist externally. (90% 失败率)
