Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [CLOUD_FIRESTORE] The service is currently unavailable. #3521

Closed
ghost opened this issue Sep 10, 2020 · 40 comments
Closed

🐛 [CLOUD_FIRESTORE] The service is currently unavailable. #3521

ghost opened this issue Sep 10, 2020 · 40 comments
Labels
platform: macos Issues / PRs which are specifically for MacOS. plugin: cloud_firestore type: documentation Improvements or additions to documentation

Comments

@ghost
Copy link

ghost commented Sep 10, 2020

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

@ghost ghost added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 10, 2020
@darshankawar
Copy link

Hi @kaiserleka,
Can you create a fresh Flutter project and try below steps to see if it works ?

  1. Setup a default Flutter project.
  2. Add cloud_firestore and firebase_core to pubspec.yaml.
  3. Create a project in Firestore. Create a collection. Create a single simple document in that collection.
  4. Follow the instructions at https://firebase.flutter.dev/docs/installation/macos to install GoogleService-Info.plist file.
  5. Initialize Firebase, following the FutureBuilder / Stateful example here: https://firebase.flutter.dev/docs/overview/#initializing-flutterfire
  6. Add import 'package:cloud_firestore/cloud_firestore.dart';
  7. Use your code sample provided above.
  8. Run app and see if you still get same error ?

Thanks.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 11, 2020
@ghost
Copy link
Author

ghost commented Sep 11, 2020

Hi @kaiserleka,
Can you create a fresh Flutter project and try below steps to see if it works ?

  1. Setup a default Flutter project.

I have created a new Flutter project and enabled desktop support.

Screen Shot 2020-09-11 at 16 25 59

  1. Add cloud_firestore and firebase_core to pubspec.yaml.

I have added both of that packages to pubspec.yaml

Screen Shot 2020-09-11 at 16 15 03

  1. Create a project in Firestore. Create a collection. Create a single simple document in that collection.

I have created new Firestore project and created a collection named "testCollection"

Screen Shot 2020-09-11 at 16 13 09

  1. Follow the instructions at https://firebase.flutter.dev/docs/installation/macos to install GoogleService-Info.plist file.

4.1 I have name my named my project

Screen Shot 2020-09-11 at 16 21 18

Screen Shot 2020-09-11 at 16 26 32

Screen Shot 2020-09-11 at 16 26 45

Screen Shot 2020-09-11 at 16 27 24

  1. Initialize Firebase, following the FutureBuilder / Stateful example here:
    https://firebase.flutter.dev/docs/overview/#initializing-flutterfire

I have located that stateful example onto my main.dart. When I run it, it works

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

void main() {
  runApp(MaterialApp(home: App()));
}

class App extends StatefulWidget {
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  // Set default `_initialized` and `_error` state to false
  bool _initialized = false;
  bool _error = false;

  // Define an async function to initialize FlutterFire
  void initializeFlutterFire() async {
    try {
      // Wait for Firebase to initialize and set `_initialized` state to true
      await Firebase.initializeApp().catchError((e) => print(e));
      setState(() {
        _initialized = true;
      });
    } catch (e) {
      // Set `_error` state to true if Firebase initialization fails
      print(e);
      setState(() {
        _error = true;
      });
    }
  }

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

  @override
  Widget build(BuildContext context) {
    // Show error message if initialization failed
    if (_error) {
      print("_error : " + _error.toString());
      return Scaffold(
        body: Center(
          child: Text("Error: " + _error.toString()),
        ),
      );
    }

    // Show a loader until FlutterFire is initialized
    if (!_initialized) {
      return Scaffold(
        body: Center(
          child: CircularProgressIndicator(),
        ),
      );
    }
    return Scaffold(
      body: Center(
        child: Text("initialized"),
      ),
    );
  }
}

  1. Add import 'package:cloud_firestore/cloud_firestore.dart';

I have added

  1. Use your code sample provided above.

I have updated my code with firestore. Event I run Firebase.initializeApp(), it says "[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()"

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

void main() {
  runApp(MaterialApp(home: App()));
}

class App extends StatefulWidget {
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  // Set default `_initialized` and `_error` state to false
  bool _initialized = false;
  bool _error = false;

  // Define an async function to initialize FlutterFire
  void initializeFlutterFire() async {
    try {
      // Wait for Firebase to initialize and set `_initialized` state to true
      await Firebase.initializeApp().catchError((e) => print(e));
      setState(() {
        _initialized = true;
      });
    } catch (e) {
      // Set `_error` state to true if Firebase initialization fails
      print(e);
      setState(() {
        _error = true;
      });
    }
  }

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

  @override
  Widget build(BuildContext context) {
    // Show error message if initialization failed
    if (_error) {
      print("_error : " + _error.toString());
      return Scaffold(
        body: Center(
          child: Text("Error: " + _error.toString()),
        ),
      );
    }

    // Show a loader until FlutterFire is initialized
    if (!_initialized) {
      return Scaffold(
        body: Center(
          child: CircularProgressIndicator(),
        ),
      );
    }
    CollectionReference users =
        FirebaseFirestore.instance.collection('testCollection');
    return Scaffold(
      body: Center(
        child: Column(children: [
          Text("initialized"),
          Divider(),
          FutureBuilder<DocumentSnapshot>(
            future: users.doc("testDocument").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("Value: ${data['testField']}");
              }

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

Screen Shot 2020-09-11 at 17 39 28

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 11, 2020
@darshankawar
Copy link

@kaiserleka,
Since firebase_core is the first and foremost important plugin after migration, initializing it is the first step to integrate firebase in your app. You can do that inside main() method itself, like below and see if it works for you.

void main() async {
  await Firebase.initializeApp();
  runApp(MyApp());
}

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 14, 2020
@ghost
Copy link
Author

ghost commented Sep 14, 2020

@kaiserleka,
Since firebase_core is the first and foremost important plugin after migration, initializing it is the first step to integrate firebase in your app. You can do that inside main() method itself, like below and see if it works for you.

void main() async {
  await Firebase.initializeApp();
  runApp(MyApp());
}

I'm getting : [core/not-initialized] Firebase has not been initialized. Please check the documentation for your platform.

bool isFirebaseReady = true;
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp().catchError((e) {
    isFirebaseReady = false;
    print(e);
  });
  runApp(MaterialApp(home: App()));
}

Why I can't find any complete Flutter Firestore Macos project :(

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 14, 2020
@darshankawar darshankawar added platform: macos Issues / PRs which are specifically for MacOS. plugin: cloud_firestore type: documentation Improvements or additions to documentation and removed Needs Attention This issue needs maintainer attention. labels Sep 17, 2020
@evanpon
Copy link

evanpon commented Sep 19, 2020

@kaiserleka - is your macos app in App Sandbox mode, and if so, did you add the com.apple.security.network.client entitlement?

@ghost
Copy link
Author

ghost commented Sep 20, 2020

@kaiserleka - is your macos app in App Sandbox mode, and if so, did you add the com.apple.security.network.client entitlement?

I have also added this to entitlement files but still getting : [core/not-initialized] Firebase has not been initialized. Please check the documentation for your platform.

<key>com.apple.security.network.client</key>
<true/>

@evanpon
Copy link

evanpon commented Sep 20, 2020

My apologies, my comment wasn't very helpful without additional context. I don't know why you are getting the Firebase has not been initialized. error. I tried looking through your code, but I'm pretty new to Flutter and wasn't able to spot the issue.

My comment about the entitlement was to address your original problem, which was that you were getting an error message about cloud_firestore being unavailable.

That said, here is a main.dart file that successfully connects to Firestore for me on macos. I imagine all the other setup (pubspec, entitlements, etc) is now similar to mine so I won't paste it all.

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
        // Initialize FlutterFire:
        future: Firebase.initializeApp(),
        builder: (context, snapshot) {
          // Check for errors
          if (snapshot.hasError) {
            return const Text("Error", textDirection: TextDirection.ltr);
          }
          if (snapshot.connectionState == ConnectionState.done) {
            return MaterialApp(
              title: 'Flutter Demo',
              theme: ThemeData(
                primarySwatch: Colors.blue,
                visualDensity: VisualDensity.adaptivePlatformDensity,
              ),
              home: MyHomePage(title: 'Flutter Demo Home Page'),
            );
          }
          return const Text("Loading", textDirection: TextDirection.ltr);
        });
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: StreamBuilder(
          stream: FirebaseFirestore.instance.collection('mycollection').snapshots(),
          builder: (context, snapshot) {
            if (!snapshot.hasData) return const Text('Loading');

            return ListView.builder(
                itemExtent: 80,
                itemCount: snapshot.data.documents.length,
                itemBuilder: (context, index) => ListTile(
                        title: Row(
                      children: [
                        Expanded(
                          child: Text(
                              snapshot.data.documents[index].data().toString()),
                        )
                      ],
                    )));
          }),
    );
  }
}

@ghost
Copy link
Author

ghost commented Sep 20, 2020

That said, here is a main.dart file that successfully connects to Firestore for me on macos. I imagine all the other setup (pubspec, entitlements, etc) is now similar to mine so I won't paste it all.

Could you share those files and related macos files just in case? Your dart code still giving that error @evanpon

@evanpon
Copy link

evanpon commented Sep 21, 2020

I created a new project from scratch, and made the (I think) minimum changes to make it work for Firestore. You can see the repo and look at the commits here: https://github.com/evanpon/macos_firestore. The one piece it doesn't have is the GoogleService-Info.plist file, since you'll need that from your own project.

@tgpsantos
Copy link

tgpsantos commented Sep 23, 2020

I'm also looking for a solution to this error. In my case I get it only when my device (Android) is offline. I'm not able to create new documents when offline due to this exception.

@findnizam
Copy link

Anyone found a solution for this. I have been trying for the last two days and couldnt find a solution.

@shinriyo
Copy link
Contributor

shinriyo commented Oct 17, 2020

[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.

it happened recently.
google products always have annoying bugs

@StephanCassel
Copy link

Same here.

Used to work like a charm but not anymore.

await Firebase.initializeApp();

await authService.signinAnonymously(); // OK

var documentSnapshot = await FirebaseFirestore.instance.collection('user').doc(deviceId).get(); // HANG

after 10 seconds or so:
The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

@loic-hamdi
Copy link

Same error on iOS 14 physical device. Anyone found a solution ?

@mtcliatt
Copy link
Contributor

mtcliatt commented Nov 4, 2020

Same issue on macos with firebase_core 0.5.1 and cloud_firestore 0.14.2

@mtcliatt
Copy link
Contributor

mtcliatt commented Nov 4, 2020

Adding the network client entitlement fixed my issue (com.apple.security.network.client). I'm guessing that App Sandbox mode is the default for macos Flutter apps, so this step should probably be added to the documentation.

@iktakahiro
Copy link

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.

@jakesterrr123
Copy link

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

@nelsonweze
Copy link

Make sure that in your android/build.gradle there is classpath 'com.google.gms:google-services:4.3.3'
Emphasis on the version. Took me the whole day

@ElaineSchwner
Copy link

The same is happening here #2753
Sadly, it is almost impossible to work with Flutter and Firebase.

@Donneto
Copy link

Donneto commented Nov 24, 2020

Any solution on this?

@mdalihusain
Copy link

I also encountered this problem, but the issue has been resolved a few days back on one of my devices.
@Ehesp I would like to confirm that this issue was not limited to FlutterFire, native Android Firebase Apps were not working as well.
I was in contact with Firebase Support, they told me that there are some issues with ISPs on which they are working to get them resolved.
For me, things are working fine now, but once in a couple of weeks, I still face this issue for 5-10 mins. And, I have noticed that when this issue occurs, even YouTube takes a long time in loading.

@dgilperez
Copy link

@nelstein do you mean, as opposed to 4.3.4, or to 3.x?

I am also being hit hard by this error.

@ElaineSchwner
Copy link

I downgraded to cloud_firestore: 0.13.6
And it started working

@Auuufff
Copy link

Auuufff commented Dec 10, 2020

I have the same error in one user in production. It's totally inappropriate behavior.

@BastianHandly
Copy link

Facing this issue too, but only on ios simulator

@loic-hamdi
Copy link

[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 ?

@iktakahiro
Copy link

#3521 (comment)

Since last December 24, the same error suddenly stopped occurring. I have not made any configuration changes or upgraded any packages. Therefore, for reasons unknown, my Sentry client has gone quiet. What about you?

@BastianHandly
Copy link

@iktakahiro

I had the issue also being solved on its own. The problem is that it's still appearing here and there which is super annoying.
It's not really explainable what the reason could be, right?

@Mayb3Nots
Copy link

I have this issue with some users but not all. Still no fix?

@nhat-tr
Copy link

nhat-tr commented Feb 7, 2021

I have the same issue with cloud_firestore 0.16.0
This is my first time using cloud firestore, and just want to do very simple tasks(add, get) but it doesn't work. Cloud Firestore seems to be not so reliable.

@RamanathanN
Copy link

I have the same issue. Same code working fine most of the time. One or two times it throws this error. Any solution for this?

@febg11
Copy link

febg11 commented Mar 3, 2021

Just started getting this on ipad.

@pravchuk
Copy link

pravchuk commented Mar 4, 2021

Make sure that in your android/build.gradle there is classpath 'com.google.gms:google-services:4.3.3'
Emphasis on the version. Took me the whole day

Thanks a lot! I updated to 4.3.4

@roeniss
Copy link

roeniss commented Mar 7, 2021

I just got the error in @zzterrozz comment suddenly. So I tried everything that 'maybe' solved this problem, and it works. I hope someone get rescue by this rambling solutions:

  1. Execute rm -rf ios/Podfile ios/Podfile.lock pubspec.lock ios/Pods && flutter clean && flutter pub get
  2. Change second line in ios/Podfile : platform :ios, '10.0' (no '#')
  3. pubspec.yaml :
# ... 
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.0

  firebase_core: ^0.7.0
  cloud_firestore: ^0.16.0+1
  firebase_auth: ^0.20.1
  firebase_crashlytics: ^0.4.0+1
  firebase_storage: ^7.0.0
  firebase_messaging: ^8.0.0-dev.15
  firebase_analytics: ^7.0.1

  intl: ^0.16.0
  equatable: ^2.0.0
  url_launcher: ^6.0.2
  device_info: ^2.0.0
  shared_preferences: ^2.0.3
  fluttertoast: ^7.1.8
  provider: ^5.0.0
  flutter_html:
  dio:
  html: 0.14.0

# ...

Today morning I upgraded to flutter 2.0. So I thought maybe it would the cause. So I tried to upgrade every firebase-related dependencies to 'null-safety version (e.g. 1.0.0)'. but it doesn't work so re-downgraded all.

  1. flutter doctor -v
[✓] Flutter (Channel stable, 2.0.1, on Mac OS X 10.15.7 19H15 darwin-x64, locale ko-KR)
    • Flutter version 2.0.1 at /usr/local/Caskroom/flutter/2.0.1/flutter
    • Framework revision c5a4b4029c (3 days ago), 2021-03-04 09:47:48 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/roeniss/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/roeniss/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/roeniss/Library/Android/sdk
    • Java binary at: /Users/roeniss/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6626763/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/roeniss/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6626763/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
    • IntelliJ at /Users/roeniss/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.54.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • iPhone 11 Pro Max (mobile) • A09F8BAA-5C6A-40E7-A3D1-BACED0EB2DBC • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 88.0.4324.192

• No issues found!
  1. Created and used another simulator.
  2. Every time I tried something, I fully quitted/deleted my debug app.

If someone need more information about my settings, please mention me. I'll gladly respond to you.


edit) I encountered this again... almost got mad... when I met this issue, my app was already in login status. So i logout and login again, then this issue was gone, again.

edit2) This still happen and I found that re-authentication is a temporary solution (I already used FB email login).

@marcsinner
Copy link

Cold restarting my flutter emulator solved it for me.

This can be done by setting "cold restart" in Android studio, see here: https://stackoverflow.com/questions/49949818/firebaseinstanceid-token-retrieval-failed-service-not-available

@IAmJulianAcosta
Copy link

IAmJulianAcosta commented Apr 7, 2021

This happened to me too (Android physical devices), but it only happened if I use release build type, if I use debug, it worked fine.

It fixed after rebuilding a couple of times, so I think that it might be related to some transient issue during build time? I can only recommend to run flutter run and when it works fine, then deploy it.

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.3, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-CO)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.55.0)
[✓] Connected device (2 available)

! Doctor found issues in 1 category.

@vhmolinar
Copy link

That error might occur whenever device is offline and there is no data inside firestore local cache. And accordingly to firebase sdk developers, it is the normal behaviour.
So, try to wrap get calls in a try/catch, handle the failure normally and you should be fine.

@dgilperez
Copy link

@vhmolinar thanks! Can you share a link to where firebase SDK developers state that, or maybe some example code about how to work around / handle this failure, please? We're seeing this error occasionally on production / release and do not know how to work around it yet. Thanks a lot!

@Salakar
Copy link
Member

Salakar commented Apr 9, 2021

Moving to discussions as this isn't an issue with FlutterFire itself. Let's continue 'discussions' there.

@Salakar Salakar closed this as completed Apr 9, 2021
@firebase firebase locked and limited conversation to collaborators Apr 9, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
platform: macos Issues / PRs which are specifically for MacOS. plugin: cloud_firestore type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests