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

Flutter项目构建失败:mobile_scanner与firebase_auth依赖冲突求助

Flutter项目mobile_scanner与firebase_auth依赖冲突解决方案

冲突核心

两个包对GTMSessionFetcher/Core的版本要求不一致:

  • firebase_auth(4.0.2)依赖GTMSessionFetcher/Core ~>2.1
  • mobile_scanner(0.0.1)依赖的GoogleMLKit链要求GTMSessionFetcher/Core ~>1.1

可行解决方案

方案1:升级mobile_scanner到兼容高版本GTMSessionFetcher的版本

  • 打开项目根目录的pubspec.yaml,将mobile_scanner的版本修改为最新稳定版(如^3.4.0,需确认当前pub.dev上的最新兼容版本)
  • 执行命令:
    flutter pub get
    cd ios
    pod install --repo-update
    
    新版mobile_scanner已升级依赖的MLKit库,适配了更高版本的GTMSessionFetcher,可直接解决版本冲突。

方案2:降级firebase_auth到兼容低版本GTMSessionFetcher的版本

  • 打开pubspec.yaml,将firebase_auth的版本修改为^3.10.0(该版本依赖的Firebase/Auth对应GTMSessionFetcher 1.x系列)
  • 执行命令:
    flutter pub get
    cd ios
    pod install --repo-update
    
    注意降级后需确认firebase_auth的功能是否满足项目现有需求。

方案3:强制CocoaPods统一GTMSessionFetcher版本(不推荐,存在风险)

  • 打开ios目录下的Podfile,在文件末尾添加:
    pod 'GTMSessionFetcher/Core', '~> 2.1'
    
  • 执行命令:
    pod install --repo-update
    
    此方法可能导致mobile_scanner依赖的MLKit库出现潜在兼容性问题,仅在前两个方案不可行时尝试。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 12:25:42