You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter打包AAB签名密钥与key.properties配置不符问题求助

问题:App Bundle签名配置无效,仍使用调试证书打包

我上传App Bundle到Play Console时,一直收到密钥不匹配提示:要求使用SHA1为38:7C:6A:52:7C:B9:77:...的证书签名,但生成的AAB用的是SHA1为8A:00:C3:60:4E:1F:EB:...的调试证书。

我的配置信息

密钥文件路径

Project_Root > android > calculadora.jks

key.properties 配置

storePassword=<mypass>
keyPassword=<mypass>
keyAlias=calculadora.<domain>
storeFile=<absolute Project_Root>/android/calculadora.jks

app/build.gradle 配置

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')

if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
...

signingConfigs {
    release {
        keyAlias = keystoreProperties['keyAlias']
        keyPassword = keystoreProperties['keyPassword']
        storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword = keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now,
        // so `flutter run --release` works.
        //signingConfig = signingConfigs.debug
        signingConfig = signingConfigs.release
    }
}

已尝试的操作

  • 执行flutter clean并删除android/.gradle文件夹
  • 使用命令flutter build appbundle --build-name=1.0.0 --build-number=1 --release打包
  • 通过keytool检测,生成的AAB仍使用调试签名

可能的原因及解决办法

1. key.properties 文件位置错误

代码中用rootProject.file('key.properties')读取配置文件,意味着文件必须放在项目根目录(不是android子目录)。如果你的key.properties在android文件夹下,需要修改代码路径为rootProject.file('android/key.properties')。

2. storeFile 路径异常

检查绝对路径是否存在空格、特殊字符,或者尝试改用相对路径:

storeFile=../calculadora.jks

(假设key.properties在项目根目录,相对路径指向android子目录下的密钥文件)

3. Gradle缓存未彻底清除

除了已执行的操作,还需:

  • 删除项目根目录下的.gradle文件夹
  • 执行flutter pub get后重新打包
  • 用Android Studio执行Build > Clean Project再Rebuild Project后生成AAB

4. 签名配置未覆盖到产品变种(若有)

如果gradle中配置了productFlavors,需要确保每个变种的release构建都指定签名配置:

productFlavors {
    production {
        ...
        signingConfig signingConfigs.release
    }
}

5. 提前验证签名配置是否生效

在打包前,通过Android Studio的Gradle面板执行android > app > Tasks > android > signingReport,查看release变体的SHA1值是否与预期一致。如果这里显示调试证书的SHA1,说明配置未生效,需回到前面步骤排查。


内容的提问来源于stack exchange,提问作者Anderson Bisconsin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 05:13:19