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

执行flutter build appbundle时遇:app:signReleaseBundle任务失败求助

解决Flutter执行flutter build appbundle时:app:signReleaseBundle空指针异常问题

以下是针对该异常的具体排查和解决步骤:

  • 检查key.properties配置准确性
    确保文件内配置项无拼写错误,重点确认storeFile路径:由于密钥文件myreleasekey.jks位于android/app目录,配置应为storeFile=myreleasekey.jks,不要添加多余的相对/绝对路径。同时保证文件内无多余空格、无效注释干扰,每一行严格遵循key=value格式。

  • 验证app/build.gradle签名配置
    确认签名配置代码位置和语法正确:

    // 在android块的最外层引入key.properties
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
    android {
        // ...其他配置
        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }
    
        buildTypes {
            release {
                signingConfig signingConfigs.release
                // ...其他release配置
            }
        }
    }
    

    注意signingConfigs需作为android块的直接子节点,不要嵌套在buildTypes内。

  • 清理构建缓存后重新构建
    执行以下命令清理旧缓存,避免缓存导致的异常:

    flutter clean
    cd android && ./gradlew clean
    cd .. && flutter build appbundle
    
  • 校验密钥文件完整性
    使用keytool命令验证myreleasekey.jks是否损坏:

    keytool -list -v -keystore android/app/myreleasekey.jks
    

    输入存储密码后若能正常显示密钥信息,说明文件正常;若报错则需重新生成密钥文件。

  • 检查Gradle版本兼容性
    打开android/build.gradle,确认Android Gradle插件版本与当前Flutter版本兼容(例如Flutter 3.x对应Gradle插件7.x及以上),避免版本不匹配引发内部任务异常。

内容的提问来源于stack exchange,提问作者강산들

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 09:31:03