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

如何移除Flutter项目调试版本?上传app-release.aab遭Google Play拒绝

Flutter AAB上传Google Play被拒(Debug签名问题)解决办法+移除调试版本指南

一、生成合规的Release签名AAB,解决上传被拒问题

1. 生成签名密钥

打开终端,执行以下命令生成签名密钥库:

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

按照提示填写密钥库密码、密钥密码等信息,完成后用户目录下会生成upload-keystore.jks文件。

2. 配置项目签名信息

在Flutter项目的android目录下新建key.properties文件,内容如下:

storePassword=你的密钥库密码
keyPassword=你的密钥密码
keyAlias=upload
storeFile=../upload-keystore.jks

如果密钥库文件放在其他路径,修改storeFile对应的路径即可。

3. 修改app/build.gradle配置

打开android/app/build.gradle,在android代码块中添加签名配置:

signingConfigs {
    release {
        keyProperties = new Properties()
        keyProperties.load(new FileInputStream(rootProject.file('key.properties')))
        storeFile file(keyProperties['storeFile'])
        storePassword keyProperties['storePassword']
        keyAlias keyProperties['keyAlias']
        keyPassword keyProperties['keyPassword']
    }
}

接着在buildTypes的release块中指定使用该签名配置:

buildTypes {
    release {
        signingConfig signingConfigs.release
        // 保留原有其他配置即可
    }
}

4. 重新生成Release版AAB

在终端执行命令:

flutter build appbundle --release

生成的合规AAB文件位于build/app/outputs/bundle/release/app-release.aab,直接上传Google Play即可。

二、移除项目中的调试版本相关内容

  • 删除代码内的Debug专属逻辑:比如基于kDebugMode判断的测试弹窗、调试日志等,直接删除或注释掉这类代码。
  • 开启Release编译的混淆压缩(可选但推荐):在android/app/build.gradle的release块中添加:
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  • 整理依赖项:将仅用于调试的依赖移到pubspec.yaml的dev_dependencies下,确保Release编译时不会打包这类依赖。

内容的提问来源于stack exchange,提问作者adham allan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 21:28:14