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

Flutter执行build appbundle失败 提示java.util.Properties无exists()方法

问题根因与修复方案

错误原因

你写的Gradle代码里调用exists()方法的对象类型错误:exists()是Java File类提供的方法,用于判断文件是否存在。但你当前代码里是对keystoreProperties对象调用该方法,而keystoreProperties是java.util.Properties类的实例,该类没有exists()方法,因此触发了方法签名不匹配的报错。

修复代码

将判断逻辑里的调用对象替换为文件实例keystorePropertiesFile即可,修正后的完整代码段如下:

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

后续验证步骤

  • 确认key.properties文件存放路径为项目根目录下的android/文件夹,而非android/app/子文件夹
  • 检查key.properties内的storeFile配置项,确认对应的jks密钥库文件路径准确无误
  • 修正后重新执行flutter build appbundle命令即可正常构建应用包

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 11:36:02