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

Flutter执行flutter build appbundle时报signingConfig.keyPassword未配置错误如何解决?

解决方案

报错本质是你没有配置Flutter安卓端Release构建所需的签名信息,signingConfig.keyPassword 字段为空导致签名配置任务执行失败,可按以下步骤修复:

步骤1:生成签名密钥文件(如果还未生成)

在本地JDK的bin目录下打开终端,执行以下命令生成签名密钥:
keytool -genkey -v -keystore 自定义密钥存储路径\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
执行过程中按提示设置存储密码、密钥密码、别名等信息,务必记住你设置的密码和别名值。

步骤2:创建签名配置文件

在Flutter项目的android/目录下新建名为key.properties的文件,填入以下内容:

storePassword=你设置的存储密码
keyPassword=你设置的密钥密码
keyAlias=你设置的密钥别名
storeFile=你的密钥文件存储绝对路径

注意:请将key.properties文件加入.gitignore规则,避免密钥信息泄露到代码仓库。

步骤3:修改安卓构建配置

打开项目路径下的android/app/build.gradle文件,做两处修改:

  1. 在android配置块上方添加读取签名配置的代码:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    // 原有android配置内容保持不变
}
  1. 找到文件内的signingConfigs和buildTypes配置块,修改Release构建的签名规则:
signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}

buildTypes {
    release {
        // 原有release配置的其他参数保持不变
        signingConfig signingConfigs.release
    }
}

步骤4:重新执行构建

回到Flutter项目根目录,重新执行构建命令即可:
flutter build appbundle


临时测试方案

如果你仅需要打测试用的AAB包,不需要上架应用商店,可以临时将buildTypes下release块的signingConfig改为调试签名:

buildTypes {
    release {
        signingConfig signingConfigs.debug
    }
}

该方式生成的包无法用于正式上架。

内容的提问来源于stack exchange,提问作者Sai Krishna Alishala

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.23 16:24:02