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

如何构建无空安全的Flutter签名release aab包并上传Google Play Console

报错根因

你收到的debug模式签名报错是因为Flutter项目安卓侧未配置正式release签名信息,即使命令加了--release参数,构建时也会默认使用系统自带的debug签名生成AAB,不符合Google Play的上传要求。

You uploaded an APK or Android App Bundle that was signed in debug mode. You need to sign your APK or Android App Bundle in release mode. Learn more about signing.

分步解决方案

第一步:生成/配置安卓正式签名

  • 如果你还没有正式签名密钥库,打开Android Studio顶部菜单栏选择Build -> Generate Signed Bundle/APK -> 选择Android App Bundle -> 点击Next -> 选择Create new,按照提示生成后缀为.jks的正式签名密钥库,妥善保存密钥库文件和你设置的密码、别名信息。
  • 在Flutter项目的android/目录下新建key.properties文件,写入以下内容(替换成你自己的签名信息):
storePassword=你的密钥库密码
keyPassword=你的密钥密码
keyAlias=你的密钥别名
storeFile=你的密钥库文件本地路径(例如/Users/xxx/签名文件.jks)

注意:请将key.properties文件加入.gitignore,避免密钥信息泄露。

  • 打开android/app/build.gradle文件,在android代码块上方添加代码加载签名配置:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    // 保留原有android块内的配置无需修改
    ...
  • 在同一个build.gradle文件的android块内,buildTypes代码块上方添加signingConfigs配置:
signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}

buildTypes {
    release {
        // 保留原有release块内的混淆等配置
        signingConfig signingConfigs.release
    }
}

第二步:构建带无空安全参数的签名AAB

两种方式二选一即可:

方式1:命令行构建

直接运行你之前的命令即可,此时构建出的AAB已经是正式签名版本,可直接上传Google Play:

flutter build appbundle --release --no-sound-null-safety

方式2:Android Studio内构建(无需找additional args选项)

打开Flutter项目根目录的android/gradle.properties文件,添加以下配置,全局指定无空安全构建参数:

flutter.extraArgs=--no-sound-null-safety

配置完成后直接在Android Studio内选择release模式构建AAB即可,构建产物自动带正式签名和无空安全参数。

内容的提问来源于stack exchange,提问作者Filia Salta

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.25 20:36:08