Home > Back-end >  Expo firebase: Could not reach Cloud Firestore
Expo firebase: Could not reach Cloud Firestore

Time:06-06

Using Expo 44, my app can fetch Firestore content properly in Expo Go with expo start. But when publishing with expo run:android, it gives following error, while auth is working properly.

[2022-06-06T03:33:09.084Z]  @firebase/firestore: Firestore (9.8.2): Could not reach Cloud Firestore 
backend. Backend didn't respond within 10 seconds.This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it 
is able to successfully connect to the backend.   
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.
(Saw setTimeout with duration 392773ms)

Possible Unhandled Promise Rejection (id: 1):
FirebaseError: Failed to get document because the 
client is offline.
construct@[native code]

I am using older version of firebase:


import firebase from "firebase/compat/app"
import firestore from 'firebase/compat/firestore';


const firebaseConfig = {
  apiKey: "",
  authDomain: "",
  projectId: ",
  storageBucket:
  messagingSenderId: 
  appId: 
  measurementId: 
};

// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);
const db = app.firestore();
export default app;

Any help is appreciated.

CodePudding user response:

It is a silly mistake. In the Firebase console I uploaded my SHA1 and SHA256 for the EAS Play Store build, so Firebase couldn't recognize the local-build app, which is not signed by Expo EAS. It works perfectly if you build (with dev-client) using eas build.

CodePudding user response:

Please make sure your android emulator have internet connection or use Expo GO app on your physical smartphone.

https://developer.android.com/studio/run/emulator-networking

  • Related