Solvedflutterfire πŸ› [CLOUD_FIRESTORE] The service is currently unavailable.

Bug report

I'm try to use Firestore with Flutter Deskop (MacOS). But I'm getting always this error since my first try for a month.

[cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

Steps to reproduce

  1. Created iosApp on Firebase and downloaded GoogleService-Info.plist file to macos project
  2. AppBundle (in Runner.xcworkspace) is edited like on Firebase
  3. Creted a collection and document on Firebase (myCollection/myDocument)
    (All steps on https://firebase.flutter.dev/docs/installation/macos)

Expected behavior

I wish to get name value from myDocument on Firebase


Additional context

main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp()
      .then((value) => print("connected " + value.options.asMap.toString()))
      .catchError((e) => print(e.toString()));
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  FirebaseFirestore firestore = FirebaseFirestore.instance;

  void _initializeApp() async {
    await Firebase.initializeApp();
  }

  @override
  void initState() {
    _initializeApp();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    CollectionReference users =
        FirebaseFirestore.instance.collection('myCollection');

    return Scaffold(
      appBar: AppBar(),
      body: FutureBuilder<DocumentSnapshot>(
        future: users.doc("myDocument").get(),
        builder:
            (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
          if (snapshot.hasError) {
            print(snapshot.error.toString());
            return Text(snapshot.error.toString());
          }

          if (snapshot.connectionState == ConnectionState.done) {
            Map<String, dynamic> data = snapshot.data.data();
            return Text("Name: ${data['name']}");
          }

          return Text("loading");
        },
      ),
    );
  }
}

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[βœ“] Flutter (Channel dev, 1.22.0-9.0.pre, on Mac OS X 10.15.5 19F101, locale en-TR)
    β€’ Flutter version 1.22.0-9.0.pre at /Users/leventkantaroglu/Development/flutter
    β€’ Framework revision 7a43175198 (13 days ago), 2020-08-28 23:18:04 -0400
    β€’ Engine revision 07e2520d5d
    β€’ Dart version 2.10.0 (build 2.10.0-73.0.dev)

[βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    β€’ Android SDK at /Users/leventkantaroglu/Library/Android/sdk
    β€’ Platform android-29, build-tools 29.0.2
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 11.5)
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Xcode 11.5, Build version 11E608c
    β€’ CocoaPods version 1.9.1

[βœ“] Chrome - develop for the web
    β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] Android Studio (version 3.5)
    β€’ Android Studio at /Applications/Android Studio.app/Contents
    β€’ Flutter plugin version 41.0.2
    β€’ Dart plugin version 191.8593
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[βœ“] VS Code (version 1.48.2)
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.14.1

[βœ“] Connected device (3 available)
    β€’ macOS (desktop)  β€’ macos      β€’ darwin-x64     β€’ Mac OS X 10.15.5 19F101
    β€’ Web Server (web) β€’ web-server β€’ web-javascript β€’ Flutter Tools
    β€’ Chrome (web)     β€’ chrome     β€’ web-javascript β€’ Google Chrome 85.0.4183.102

β€’ No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.10.0-73.0.dev
Flutter SDK 1.22.0-9.0.pre
flutter_desktop_macos 1.0.0+1

dependencies:
- cloud_firestore 0.14.0+2 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- cupertino_icons 0.1.3
- firebase_core 0.5.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- async 2.5.0-nullsafety [collection]
- boolean_selector 2.1.0-nullsafety [source_span string_scanner]
- characters 1.1.0-nullsafety.2
- charcode 1.2.0-nullsafety
- clock 1.1.0-nullsafety
- cloud_firestore_platform_interface 2.0.1 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.2.0+1 [flutter flutter_web_plugins firebase http_parser meta firebase_core cloud_firestore_platform_interface js]
- collection 1.15.0-nullsafety.2
- fake_async 1.1.0-nullsafety [clock collection]
- firebase 7.3.0 [http http_parser js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- js 0.6.2
- matcher 0.12.10-nullsafety [stack_trace]
- meta 1.3.0-nullsafety.2
- path 1.8.0-nullsafety
- pedantic 1.9.0
- plugin_platform_interface 1.0.2 [meta]
- quiver 2.1.3 [matcher meta]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety [path]
- stream_channel 2.1.0-nullsafety [async]
- string_scanner 1.1.0-nullsafety [charcode source_span]
- term_glyph 1.2.0-nullsafety
- test_api 0.2.19-nullsafety [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.2 [collection]
- vector_math 2.1.0-nullsafety.2

41 Answers

βœ”οΈAccepted Answer

[cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

Keeps happening...!! what is going on ?

Other Answers:

Hi, same error here, on physical Android devices. Firestore client throws same error randomly.

[cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.
  • firebase_core: 0.5.1
  • cloud_firestore: 0.14.2

In my case, a network connection of those devices were active. In addition, I already implemented a retry process using the exponential backoff algorithm. However, this issue is not resolved.

Same here. My app was working fine until about 2 weeks ago, and now I'm getting that error about 70% of the times I try and start the app

More Issues: