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

使用FVM构建Flutter APK时遇签名配置错误,求解决方案

Flutter构建APK时签名配置缺失storeFile错误解决方案

问题场景

执行构建命令:

fvm flutter build apk

触发以下错误:

PS C:\Users\ARcaN\Desktop\otrack_flutter_app> fvm flutter build apk

 Building with sound null safety 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageDevRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > SigningConfig "release" is missing required property "storeFile".

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4m 11s
Running Gradle task 'assembleRelease'...                          255.1s
Gradle task assembleRelease failed with exit code 1

当前签名配置代码:

signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

解决步骤

  • 确认项目android/目录下存在keystore.properties文件,且文件中正确配置storeFile项,示例格式:
    keyAlias=你的密钥别名
    keyPassword=你的密钥密码
    storeFile=../你的密钥库文件.jks
    storePassword=你的密钥库密码
    
  • 验证密钥库文件(如.jks)是否存在于storeFile指定的路径中,路径支持相对android/目录的相对路径或绝对路径
  • 若未生成密钥库,先通过keytool生成,命令示例:
    keytool -genkey -v -keystore ~/my_key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my_key
    
    生成后将.jks文件复制到项目合适位置,再更新keystore.properties的路径配置
  • 检查android/app/build.gradle开头是否正确加载配置文件,需包含以下代码:
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('keystore.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
  • 若仅用于测试构建,可临时改用调试签名(正式发布请勿使用):
    修改buildTypes配置:
    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 14:18:20