invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.63k stars 2.2k forks source link

[🐛] Expo + Authentication - `No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()` #7947

Open loyddaniels opened 1 month ago

loyddaniels commented 1 month ago

Issue

When following the documentation for authentication I get the error No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

image

Project Files

Javascript

Click To Expand

#### App.tsx import * as React from 'react'; import { Text } from 'react-native'; import auth from '@react-native-firebase/auth'; export default function App() { const user = auth().currentUser; if (!user) { return Please login; } return Welcome {user.email}; } #### `package.json`: ```json { "name": "auth", "version": "1.0.0", "main": "expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web" }, "dependencies": { "@react-native-async-storage/async-storage": "1.23.1", "@react-native-firebase/app": "^20.3.0", "@react-native-firebase/auth": "^20.3.0", "expo": "~51.0.22", "expo-build-properties": "~0.12.3", "expo-dev-client": "~4.0.20", "expo-status-bar": "~1.12.1", "firebase": "^10.12.4", "react": "18.2.0", "react-native": "0.74.3" }, "devDependencies": { "@babel/core": "^7.20.0", "@types/react": "~18.2.45", "typescript": "^5.1.3" }, "private": true } ``` #### `firebase.json` for react-native-firebase v6: ```json ```

iOS

Click To Expand

#### `ios/Podfile`: I'm using expo - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` ERROR Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() ``` - **Platform that you're experiencing the issue on**: - [x] expo - [x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `20.3.0` - **`Firebase` module(s) you're using that has the issue:** - `auth` - **Are you using `TypeScript`?** - Yes, 5.5.4


russellwheatley commented 1 month ago

Seems unlikely something so fundamental to React Native Firebase is broken. Please provide a repo with minimal-reproducible-example to illustrate this behaviour. i.e app + auth Firebase dependencies.

Bohooslav commented 1 week ago

Any progress? I also have this issue but without expo and on Android .

anthlasserre commented 1 week ago

Can you share your app.json ? You have probably forgotten to add the Firebase libraries within the Expo plugins.

https://rnfirebase.io/#configure-react-native-firebase-modules

{
  ...
  "plugins": [
    "@react-native-firebase/app"
    "@react-native-firebase/auth"
    "@react-native-firebase/crashlytics",
    [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
  ],
  ...
}
Bohooslav commented 1 week ago

Some of the reasons may be unmatching aplicationId package name of the app. Also in my case, am building replacement for an old xamarine app, I have to add new SHA1 keys of my new keystore to Firebase project but for some reason Firebase doesn't refresh the google-service.json file and it just wont work with new keystore, while I have no access to the old one. These are reasons I faced.