react本机应用程序上的rnfirebase don';行不通

react本机应用程序上的rnfirebase don';行不通,firebase,react-native,google-cloud-firestore,react-native-firebase,Firebase,React Native,Google Cloud Firestore,React Native Firebase,我有以下几点: "react-native": "0.62.2", "@react-native-firebase/app": "^7.0.1", "@react-native-firebase/firestore": "^7.0.1", 在我的项目中,我通过以下url对现有项目执行了rnfirebase结构: 我补充说: buildscript { dependencies { // ... other dependencies classpath 'com.googl

我有以下几点:

"react-native": "0.62.2",
"@react-native-firebase/app": "^7.0.1",
"@react-native-firebase/firestore": "^7.0.1",
在我的项目中,我通过以下url对现有项目执行了rnfirebase结构:

我补充说:

buildscript {
  dependencies {
    // ... other dependencies
    classpath 'com.google.gms:google-services:4.2.0'
    // Add me --- /\
  }
}
为了我的身材,格雷德尔

这是:

apply plugin: 'com.google.gms.google-services'
在我的应用程序/build.gradle中,还将从firebase控制台下载的google-services.json放在/app目录中

然后我使用了firestore软件包,如下所示:

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'));
  });
在我的应用程序中,但没有显示在react native debugger中进行的xhr连接没有控制台日志错误或成功!没什么


我已经卸载了rnfirebase/app和rnfirebase/firestore软件包,并通过react native运行android卸载然后重建了应用程序,但什么都没发生

经过三天的努力,我才发现问题所在,那是模拟器的互联网连接

在谷歌搜索应用程序中,我有网络连接,但在我的应用程序中,没有连接到firebase的互联网连接! 因此,解决方案是通过以下命令在特定dns上运行emulator:

emulator -avd Pixel_2_API_29  -dns-server 8.8.8.8

经过三天的努力,我才发现问题所在,那是模拟器的互联网连接

在谷歌搜索应用程序中,我有网络连接,但在我的应用程序中,没有连接到firebase的互联网连接! 因此,解决方案是通过以下命令在特定dns上运行emulator:

emulator -avd Pixel_2_API_29  -dns-server 8.8.8.8

检查应用插件:“com.google.gms.google services”是否放在android/app/build.gradle/的底部,同时检查您是否运行了以下命令:npm install@react native firebase/appYes我已经完成了测试,如果您启用了云firestore的写入和读取规则。谢谢@MIPB这是模拟器的互联网连接我把底部回答检查应用插件:“com.google.gms.google services”是否放在android/app/build.gradle/的底部,同时检查您是否运行了以下命令:npm install@react native firebase/appYes如果您启用了云firestore的写入和读取规则,我已经完成了两项测试。谢谢@MIPB这是模拟器internet我把答案放在底部