1
votes

I have this dependencies:

"react-native": "0.62.2",
"@react-native-firebase/app": "^7.0.1",
"@react-native-firebase/firestore": "^7.0.1",

In my project I have done rnfirebase structure on my existing project from this url: react native firebase

I have added this:

buildscript {
  dependencies {
    // ... other dependencies
    classpath 'com.google.gms:google-services:4.2.0'
    // Add me --- /\
  }
}

To my build.gradle

And this:

apply plugin: 'com.google.gms.google-services'

To my app/build.gradle also placed downloaded google-services.json from firebase console in /app directory

Then I have used firestore package like this:

import firestore from '@react-native-firebase/firestore';
useEffect(() => {
    console.log('on load');

    firestore()
      .collection('users')
      .add({
        name: 'Hello firebase',
      })
      .then(() => {
        console.log('success');
      })
      .catch(err => console.log(err, 'error'));
  });

In my app, but noting appears no xhr connection made in react native debugger no console log error or success! Nothing!

I have done uninstall rnfirebase/app and rnfirebase/firestore packages and uninstalled then rebuild app by react-native run-android but nothing happened!

1
Check if apply plugin: 'com.google.gms.google-services' is placed at the BOTTOM of android/app/build.gradle / Also check that you ran this command: npm install @react-native-firebase/appMIPB
Yes I have done bothRoham Shojaei
Test if you have the rules for cloud firestore enabled to write and read.MIPB
Thank you @MIPB it was emulators internet connection I put the answer on the bottomRoham Shojaei

1 Answers

0
votes

After struggling for three days I just fount the problem and it was emulators internet connection!!

With google search app I had network connection, but on my app there was no internet connection to connect to firebase! So the solution was to run emulator on specific dns by this command:

emulator -avd Pixel_2_API_29  -dns-server 8.8.8.8