I recently built a react native app that I have linked to firebase. It works perfectly fine on the iOS simulator. However, I recently began setting up the android emulator and I am now having issues. The app has authentication supported by firebase, but when logging in on the android emulator, I constantly get this error message in the terminal and cannot log in:
@firebase/firestore: Firestore (9.6.10): 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.
In the app itself, it says:
FirebaseError: [code=unavailable]: Failed to get document because the client is offline.
I have the google-services.json file at android/app/src level, and my config.js file for the app looks like the below:
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
const firebaseConfig = {
apiKey: 'xxxxxxx',
authDomain: 'xxxxxxx',
projectId: 'xxxxxxx',
storageBucket: 'xxxxxxx',
messagingSenderId: 'xxxxxxx',
appId: 'xxxxxxx',
measurementId: 'xxxxxxx',
};
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
export {firebase};
Any idea why this wouldn't be working? Like I said, it works perfectly fine for iOS so I'd assume the error is not in my config file and is instead in my android/firebase setup. I added the other components to both build.gradle files that were mentioned on the firebase website's setup instructions.
Edit: I can create a new account and sign in under that account, but I cannot sign in from an existing account.
UPDATE: I deployed this fore testing to the google play console and it works there. I am assuming the problem is related to something on my machine that is blocking the request to firebase and NOT my configuration. I have read that wifi settings on the emulator can cause this or firewalls/vpns can cause issues. Will look into that and update if I find anything (for anyone who is interested in the future).