1
votes

Hi I am using Below package in react-native app https://www.npmjs.com/package/firebase

My app uses firebase and firestore both I have no issue in ios app But in android app (firebase/firestore is not getting connected to internet)

Any idea ?

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

Android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        google()
        jcenter()
        google()  // Google's Maven repository
    }
    dependencies {
        classpath('com.android.tools.build:gradle:4.1.0')
        classpath 'com.google.gms:google-services:4.3.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()  // Google's Maven repository
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}
2
Just clean and rebuild the app. Or reinstall NPM packages. Happens Sometimes due to cache or some small issue. - fatalcoder524
@fatalcoder524 I tried running npm install command and re-installing Android App. but didnt get it worked - Jatin Garg
Which device are you testing? If its an android emulator, Is it having GOogle Play services installed?? And Can you paste the logcat when the app is running? Logcat helps to debug the issue easily. - fatalcoder524
I tried on Android Emulator Nexus 6P and real device Galaxy Tab A 10.1 both has same issue - Jatin Garg
Did you create a new android Application in firebase console and add the google-services.json in /android/app/ ??? - fatalcoder524

2 Answers

0
votes

From the chat, I notice that you have not created Android app in Firebase console. Please create the app and generate the credentials and paste it in /android/app/. For more info on How to configure React Native app for Android and iOS, visit here.

-1
votes

In Android, we need request Internet permission for network action, maybe you missing it, let check your manifest.