'cloud_firestore/unavailable The service is currently unavailable

I am using Firebase Firestore in my flutter application. Everything works fine in debug mode. But, in release mode I get the following error. I saw a similar question, but it doesn't solve my issue.

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: [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.
E/flutter ( 3646): #0      MethodChannelDocumentReference.get 
(package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:80)
E/flutter ( 3646): <asynchronous suspension>
E/flutter ( 3646): #1      DocumentReference.get (package:cloud_firestore/src/document_reference.dart:58)
E/flutter ( 3646): <asynchronous suspension>
$ flutter doctor
>> Flutter (Channel stable, 2.2.3, Version 10.0.21996.1)
>> • No issues found!

I tried

  • Adding INTERNET permission.
  • Changing Gradle Versions.
  • Changing Firebase package versions

Current Versions

firebase_core: 1.6.0
firebase_auth: 2.0.0
cloud_firestore: 1.0.7

Any help/suggestions would be so grateful.



Solution 1:[1]

Upgrading Firebase core and Firestore to the latest version solved the issue for me.

Solution 2:[2]

Build using

flutter build --no-shrink

or go to Android > app > build.gradle and add

buildTypes {

    release {
        shrinkResources false
        minifyEnabled false
        signingConfig signingConfigs.release
        
    }
}

Solution 3:[3]

I think it is not an issue of library. It is coding issue, please check some below ways to fix it:

  • Option 1: Upgrading cloud_firestore and firebase core to latest version, then running command flutter clean and flutter run.
  • Option 2: Firebase profile issue.
  1. Checking Firebase profile in production mode or test mode?. Try to switch it for testing.
  2. Checking collection is exist. ie users is exist on firestore?
  • Option 3: The logged-in user didn't exist on the auth emulator and Firestore kept refusing to return the data to the unauthorized user. So please log out and created a new user account.

That's it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hooshyar
Solution 2
Solution 3 nahoang