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

Flutter Firebase调用Firestore时Google Play Services异常报错求助

解决Flutter Firestore因Google Play Store缺失导致的报错

报错信息

W/GooglePlayServicesUtil(16697): com.example.try_1 requires the Google Play Store, but it is missing.
E/GooglePlayServicesUtil(16697): GooglePlayServices not available due to error 9
W/Firestore(16697): (24.7.0) [GrpcCallProvider]: Failed to update ssl context: com.google.android.gms.common.GooglePlayServicesNotAvailableException

问题原因

Firebase Firestore依赖Google Play Services提供的底层网络安全、身份验证等服务,当前测试设备未安装Google Play Store,导致Google Play Services无法正常初始化,进而引发Firestore的SSL上下文更新失败,无法连接云端数据库。

解决方案

  • 使用带Google Play服务的模拟器
    打开Android Studio的AVD Manager,创建或选择带有Google Play标识的模拟器镜像(例如Pixel系列的官方镜像,需选择包含Google Play的版本)。这类模拟器预装完整的Google Play Store和Google Play Services,可直接满足Firestore运行要求。

  • 为实体设备安装Google Play服务
    若使用实体安卓设备,需确保设备已安装Google Play Store并登录Google账号,同时将Google Play Services更新至最新版本。部分国内定制ROM未预装GMS,需自行刷入适配设备的Google服务框架及Google Play Store安装包。

  • 临时启用Firestore离线模式
    仅用于本地功能调试时,可开启Firestore离线模式,依赖本地缓存数据运行,无需连接云端:

    FirebaseFirestore.instance.settings = const Settings(
      persistenceEnabled: true,
      cacheSizeBytes: Settings.CACHE_SIZE_UNLIMITED,
    );
    

    注意:离线模式无法与云端同步数据,仅适用于本地逻辑验证。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 18:43:18