0

I have a React Native app that was built using Expo. At launch it connects to Firestore and attempts to load 3 documents from a particular collection. It happens that at the moment that collection temporarily has no security restrictions. The app words great in the Expo emulation environment or when I've used a build from Expo to create an APK of the app.

Here's the problem. I have used the expo run:android command to export the code, built and installed the app and tried running it on either an emulator OR an Android phone (via WiFi or USB). In these cases when the app launches, it gets this error:

@firebase/firestore: Firestore (8.7.0): 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.

To try to troubleshoot this further, I inserted a fetch (using node-fetch) to a web site just to do a GET request. I did that just before the first Firestore code. It succeeds in all these environments, so I am certain it's not a network connectivity issue. There must be something about my Firebase app config, the identity of the app or something else that is either blocking this at a security level or needs to be configured on the device for Firestore access to work.

What should I explore? Are there diagnostic details I can provide that would help figure this out? These are the npm versions if you are curious.

    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/slider": "3.0.3",
    "@react-navigation/bottom-tabs": "5.11.2",
    "@react-navigation/drawer": "^5.12.5",
    "@react-navigation/native": "~5.8.10",
    "@react-navigation/stack": "~5.12.8",
    "diff-match-patch": "^1.0.5",
    "diff-match-patch-line-and-unicode-aware-word": "^0.2.2",
    "eslint": "^7.23.0",
    "expo": "^42.0.0",
    "expo-asset": "~8.3.2",
    "expo-av": "~9.2.3",
    "expo-constants": "~11.0.1",
    "expo-font": "~9.2.1",
    "expo-intent-launcher": "~9.1.0",
    "expo-linking": "~2.3.1",
    "expo-localization": "~10.2.0",
    "expo-network": "~3.2.0",
    "expo-permissions": "~12.1.1",
    "expo-splash-screen": "~0.11.2",
    "expo-status-bar": "~1.0.4",
    "expo-web-browser": "~9.2.0",
    "firebase": "^8.7.0",
    "git": "^0.1.5",
    "i18n-js": "^3.8.0",
    "install": "^0.13.0",
    "lodash": "^4.17.21",
    "moment": "^2.29.1",
    "npm": "^7.6.3",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "~0.63.4",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-material-menu": "^1.2.0",
    "react-native-popup-menu": "^0.15.10",
    "react-native-progress": "^4.1.2",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.4.0",
    "react-native-tiny-toast": "^1.0.7",
    "react-native-web": "~0.13.12",
    "react-native-webview": "11.6.2",
    "expo-updates": "~0.8.0",
    "react-native-reanimated": "~2.2.0",
    "react-native-unimodules": "~0.14.3"
Fitter Man
  • 682
  • 8
  • 17
  • Try to read android studio log, maybe you have more clues – Francesco Clementi Jul 08 '21 at 06:31
  • I dug through the logs. There was nothing related to execution and the build warnings all had to do with gradle settings. I tried tweaking those (based on online suggestions), but nothing. The app clearly builds and runs, but the Firestore access is what's choking. – Fitter Man Jul 08 '21 at 15:20

1 Answers1

0

I found a lot of useful suggestions to a related question and among the answers was a suggestion to try long polling.

firebase.firestore().settings({experimentalForceLongPolling: true})

I also attempted to use the following, but it did not work consistently.

firebase.firestore().settings({experimentalAutoDetectLongPolling: true, merge: true})

You can find more information about these two settings in the [Firebase Firestore documentation.

Fitter Man
  • 682
  • 8
  • 17