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

Flutter构建APK时key.properties配置异常报错无法正常打包问题求助

Flutter安卓APK构建签名配置报错排查方案
  • 首先检查key.properties文件存放路径:必须放在安卓模块根目录(即项目android/文件夹下,而非android/app/目录或项目根目录)
  • 检查key.properties内容语法:

    不要加多余引号、首尾空格,属性值直接填写即可,正确格式参考:

    storePassword=密钥库密码
    keyPassword=密钥密码
    keyAlias=密钥别名
    storeFile=密钥文件路径(如密钥放在android/app目录下可直接写文件名,如xxx.jks)
    
  • 检查android/build.gradle中读取key.properties的代码逻辑,必须放在android配置块之前,示例代码:
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
    android {
        // 原有配置内容
    }
    
  • 检查android/app/build.gradle中的签名配置块,读取属性的键名必须和key.properties中的定义完全匹配,示例代码:
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            // 其余原有配置内容
        }
    }
    
  • 检查密钥文件(.jks/.keystore格式)的实际路径和key.properties中storeFile的配置完全匹配,注意相对路径是相对于android/app/目录计算
  • 确认密钥密码、别名等信息无拼写错误、大小写错误,所有符号均为英文半角格式,无全角特殊符号

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.06 09:45:00