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

因speech_to_text库导致Flutter打包失败问题求助

Flutter assembleRelease打包失败解决方案

以下是针对你遇到的speech_to_text相关打包错误的具体修复步骤:

  • 清理依赖缓存
    执行命令清理项目缓存:

    flutter clean
    

    删除项目根目录及android目录下的.gradle文件夹,再运行flutter pub get重新拉取依赖,最后在Android Studio中执行Sync Project with Gradle Files。

  • 统一Kotlin Gradle插件版本
    打开android/build.gradle文件,修改buildscript块中的Kotlin版本为与当前Flutter版本兼容的稳定版(例如1.7.20),确保插件依赖配置正确:

    buildscript {
        ext.kotlin_version = '1.7.20'
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
            classpath "com.android.tools.build:gradle:7.4.2"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
  • 更新Gradle插件应用语法
    检查所有模块的build.gradle文件,将过时的插件应用语法替换为新格式:
    旧写法(需替换):

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    

    新写法:

    plugins {
        id 'com.android.application'
        id 'kotlin-android'
    }
    
  • 清理残留依赖引用
    打开pubspec.lock文件,搜索并删除所有speech_to_text相关条目,再执行flutter pub get;同时检查android/settings.gradle,确保没有残留的:speech_to_text项目引用。

  • 匹配Gradle与插件版本
    打开gradle/wrapper/gradle-wrapper.properties,确保Gradle版本与Android Gradle Plugin版本匹配,例如:

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
    

内容的提问来源于stack exchange,提问作者Fatih Durmuş

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 22:16:01