Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] Metro error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() #8395

Closed
furkananter opened this issue Mar 7, 2025 · 21 comments
Labels

Comments

@furkananter
Copy link

Hi, I am getting this error while trying to eas build (production) and Xcode Archive.

Development Build has no issues. Everything looks like it was expected.

Metro error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
  Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
    at call (/Users/expo/workingdir/build/node_modules/@react-native-firebase/app/lib/internal/registry/app.js:96:11)
    at getApp (/Users/expo/workingdir/build/node_modules/@react-native-firebase/app/lib/modular/index.js:75:23)
    at getAuth (/Users/expo/workingdir/build/node_modules/@react-native-firebase/auth/lib/modular/index.js:52:16)
    at factory (/Users/expo/workingdir/build/context/FirebaseProvider.tsx:31:21)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at factory (/Users/expo/workingdir/build/app/(auth)/(tabs)/_layout.tsx:13:1)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:177:21)
No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
    at call (/Users/expo/workingdir/build/node_modules/@react-native-firebase/app/lib/internal/registry/app.js:96:11)
    at getApp (/Users/expo/workingdir/build/node_modules/@react-native-firebase/app/lib/modular/index.js:75:23)
    at getAuth (/Users/expo/workingdir/build/node_modules/@react-native-firebase/auth/lib/modular/index.js:52:16)
    at factory (/Users/expo/workingdir/build/context/FirebaseProvider.tsx:31:21)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at factory (/Users/expo/workingdir/build/app/(auth)/(tabs)/_layout.tsx:13:1)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:177:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn expo export:embed --eager --platform ios --dev false exited with non-zero code: 1

My app.json looks like this:

{
  "expo": {
    "name": "name",
    "slug": "slug",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "scheme",
    "userInterfaceStyle": "automatic",
    "newArchEnabled": true,
    "ios": {
      "supportsTablet": false,
      "associatedDomains": ["applinks:..."],
      "bundleIdentifier": "id",
      "usesAppleSignIn": true,
      "googleServicesFile": "./GoogleService-Info.plist",
      "infoPlist": {
        "NSCameraUsageDescription": "$(PRODUCT_NAME) needs access to your Camera.",
        "ITSAppUsesNonExemptEncryption": false
      },
      "appleTeamId": "id"
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#fff"
      },
      "package": "packageid",
      "permissions": [
        "android.permission.CAMERA",
        "com.google.android.gms.permission.AD_ID"
      ],
    },
    "web": {
      "bundler": "metro",
      "output": "server",
      "favicon": "./assets/images/favicon.png"
    },
    "plugins": [
      "expo-router",
      "expo-localization",
      "expo-apple-authentication",
      "expo-dev-client",
      "@react-native-firebase/app",
      "@react-native-firebase/auth",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ],
      [
        "onesignal-expo-plugin",
        {
          "devTeam": "id",
          "mode": "production"
        }
      ]
    ],
    "experiments": {
      "typedRoutes": true
    },
  }
}

Packages:

    "@react-native-firebase/app": "^21.12.0",
    "@react-native-firebase/auth": "^21.12.0",
    "@react-native-firebase/firestore": "^21.12.0",
    "@react-native-firebase/storage": "^21.12.0",

Can you please help? I am not using initializeApp in anywhere.

@mikehardy
Copy link
Collaborator

looks promising that you've got the react-native-firebase plugins in there

You cut out most of your package.json so I can't see what Expo you are on - I think we support the new AppDelegate.swift with the expo config plugin now, as of 21.9.0 in fact (6a7867c) so it should be working

Looks to me like a project configuration / setup / install issue somehow - I'd triplecheck everything to make sure that config plugin is executing as it should be processing the ios AppDelegate file and adding the call to configure that handles this

If it's working in dev that's a strong hint that it should be working, I don't know what the difference is on EAS build, you might contact Expo support since dev builds are working - they may know more about dev build -> EAS build/archive difference

@omerkars78
Copy link

Same error

@furkananter
Copy link
Author

furkananter commented Mar 7, 2025

looks promising that you've got the react-native-firebase plugins in there

You cut out most of your package.json so I can't see what Expo you are on - I think we support the new AppDelegate.swift with the expo config plugin now, as of 21.9.0 in fact (6a7867c) so it should be working

Looks to me like a project configuration / setup / install issue somehow - I'd triplecheck everything to make sure that config plugin is executing as it should be processing the ios AppDelegate file and adding the call to configure that handles this

If it's working in dev that's a strong hint that it should be working, I don't know what the difference is on EAS build, you might contact Expo support since dev builds are working - they may know more about dev build -> EAS build/archive difference

I am using this packages:

"dependencies": {
    "@babel/runtime": "^7.26.0",
    "@expo/vector-icons": "^14.0.2",
    "@gorhom/bottom-sheet": "^5.0.6",
    "@legendapp/list": "1.0.0-beta.11",
    "@lottiefiles/dotlottie-react": "^0.13.0",
    "@react-native-community/checkbox": "^0.5.17",
    "@react-native-community/datetimepicker": "8.2.0",
    "@react-native-firebase/app": "^21.12.0",
    "@react-native-firebase/auth": "^21.12.0",
    "@react-native-firebase/firestore": "^21.12.0",
    "@react-native-firebase/storage": "^21.12.0",
    "@react-native-google-signin/google-signin": "^13.2.0",
    "@react-native-menu/menu": "^1.2.0",
    "@react-native-picker/picker": "2.9.0",
    "@react-navigation/drawer": "^7.1.1",
    "@react-navigation/native": "^7.0.14",
    "@reduxjs/toolkit": "^2.2.7",
    "aes-js": "^3.1.2",
    "crypto-js": "^4.2.0",
    "expo": "~52.0.26",
    "expo-apple-authentication": "~7.1.3",
    "expo-application": "~6.0.1",
    "expo-blur": "~14.0.3",
    "expo-build-properties": "~0.13.1",
    "expo-clipboard": "~7.0.0",
    "expo-constants": "~17.0.3",
    "expo-dev-client": "~5.0.10",
    "expo-device": "~7.0.1",
    "expo-document-picker": "~13.0.3",
    "expo-file-system": "~18.0.6",
    "expo-font": "~13.0.2",
    "expo-haptics": "~14.0.0",
    "expo-image": "~2.0.3",
    "expo-image-manipulator": "~13.0.6",
    "expo-image-picker": "~16.0.3",
    "expo-linear-gradient": "~14.0.1",
    "expo-linking": "~7.0.3",
    "expo-localization": "~16.0.0",
    "expo-media-library": "~17.0.4",
    "expo-notifications": "~0.29.11",
    "expo-router": "~4.0.17",
    "expo-splash-screen": "~0.29.21",
    "expo-status-bar": "~2.0.0",
    "expo-system-ui": "~4.0.6",
    "expo-tracking-transparency": "~5.1.0",
    "expo-web-browser": "~14.0.1",
    "i18next": "^23.15.1",
    "lottie-react-native": "7.1.0",
    "lucide-react-native": "^0.469.0",
    "onesignal-expo-plugin": "^2.0.3",
    "posthog-react-native": "^3.11.2",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-hook-form": "^7.54.2",
    "react-i18next": "^15.0.1",
    "react-native": "0.76.7",
    "react-native-compressor": "^1.10.3",
    "react-native-crypto": "^2.2.0",
    "react-native-gesture-handler": "~2.20.2",
    "react-native-ios-context-menu": "^3.1.0",
    "react-native-ios-utilities": "^5.1.1",
    "react-native-keyboard-controller": "^1.15.2",
    "react-native-keychain": "^9.2.2",
    "react-native-markdown-display": "^7.0.2",
    "react-native-mmkv": "^3.2.0",
    "react-native-onesignal": "^5.2.9",
    "react-native-pager-view": "6.5.1",
    "react-native-purchases": "^8.2.1",
    "react-native-purchases-ui": "^8.7.0",
    "react-native-randombytes": "^3.6.1",
    "react-native-reanimated": "~3.16.1",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "~4.4.0",
    "react-native-sse": "^1.2.1",
    "react-native-svg": "15.8.0",
    "react-native-uuid": "^2.0.3",
    "react-native-web": "~0.19.10",
    "react-native-zoom-toolkit": "^4.0.1",
    "react-redux": "^9.1.2",
    "sonner-native": "^0.17.0",
    "yup": "^1.6.1",
    "zeego": "^2.0.4",
    "zod": "^3.24.1"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/aes-js": "^3.1.4",
    "@types/crypto-js": "^4.2.2",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.3.12",
    "@types/react-native-get-random-values": "^1.8.2",
    "@types/react-test-renderer": "^18.0.7",
    "babel-plugin-module-resolver": "^5.0.2",
    "eslint": "^8.57.0",
    "eslint-config-expo": "~8.0.1",
    "react-native-svg-transformer": "^1.5.0",
    "react-test-renderer": "18.2.0",
    "typescript": "~5.3.3"
  },

Also, there are no differences between the Xcode archive and the eas build. I am still getting the same errors.

I rebuilt it for development and everything works fine. I am trying to archive and send it to the Testflight but I can't get the archive build.

@mikehardy

@mikehardy
Copy link
Collaborator

mikehardy commented Mar 8, 2025

I hear what you are saying, however I don't personally use Expo - sorry - so I'm just not aware of what the differences are between a dev build and whatever Expo does for a production / archive build. I understand this seems a bit like passing the buck however, please consider:

  • we do host a config plugin, and it must be working because it works in dev?
  • the app itself works in dev indicating our module code is working?

I'm not sure how we can be responsible for build variations between dev and archive in an Expo context. That feels like an Expo issue to me

@furkananter
Copy link
Author

I hear what you are saying, however I don't personally use Expo - sorry - so I'm just not aware of what the differences are between a dev build and whatever Expo does for a production / archive build. I understand this seems a bit like passing the buck however, please consider:

  • we do host a config plugin, and it must be working because it works in dev?
  • the app itself works in dev indicating our module code is working?

I'm not sure how we can be responsible for build variations between dev and archive in an Expo context. That feels like an Expo issue to me

@mikehardy
The app is working on Development.
Can you check these logs, please? It looks like polyfills has issues

Metro error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

  Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
    at call (/…/node_modules/@react-native-firebase/app/lib/internal/registry/app.js:96:11)
    at getApp (/…/node_modules/@react-native-firebase/app/lib/modular/index.js:75:23)
    at getAuth (/…/node_modules/@react-native-firebase/auth/lib/modular/index.js:52:16)
    at factory (/…/context/FirebaseProvider.tsx:26:21)
    at loadModuleImplementation (/…/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/…/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/…/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at factory (/…/app/(auth)/(tabs)/_layout.tsx:13:1)
    at loadModuleImplementation (/…/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/…/node_modules/metro-runtime/src/polyfills/require.js:177:21)
error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
    at call (/…/node_modules/@react-native-firebase/app/lib/internal/registry/app.js:96:11)
    at getApp (/…/node_modules/@react-native-firebase/app/lib/modular/index.js:75:23)
    at getAuth 

> (/…/node_modules/@react-native-firebase/auth/lib/modular/index.js:52:16)

    at factory (/…/context/FirebaseProvider.tsx:26:21)
    at loadModuleImplementation (/…/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/…/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/…/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at factory (/…/app/(auth)/(tabs)/_layout.tsx:13:1)
    at loadModuleImplementation (/…/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/…/metro-runtime/src/polyfills/require.js:177:21)

I can't have a build. What do you recommend?

@mikehardy
Copy link
Collaborator

It looks like polyfills has issues

doesn't look like that to me. just because it's a stack frame doesn't mean it's a cause.

Looks to me like whatever unknown thing EAS is doing to build, it's not applying the @react-native-firebase/app expo config plugin correctly, so AppDelegate file is not being modified correctly to call the firebase configure method.

That's my hunch. Root cause though? No idea.

Please don't ignore this - it's my best advice:

I'm not sure how we can be responsible for build variations between dev and archive in an Expo context. That feels like an Expo issue to me

@MichaelVerdon MichaelVerdon added platform: ios plugin: app-core Firebase Apps / Core internals. labels Mar 10, 2025
@SulthanNK
Copy link

I'm facing this issue in the (non expo) react native app in the iOS only (works fine in android) even in the debug mode.

Currently, Using version

react-native: 0.75.2
@react-native-firebase/app : 16.5.0

@MichaelVerdon
Copy link
Collaborator

Hey there @SulthanNK can you please try upgrading your Firebase and seeing if the issue persists as that is quite an old version.

@MichaelVerdon
Copy link
Collaborator

Hey there @furkananter I have always found things to be a bit finicky on expo. I see you said you are not using initializeApp(), can I please get you to try it with that?

@mikehardy
Copy link
Collaborator

@SulthanNK if you would like to see a correctly integrated project you should read + try executing this demo build script that starts from scratch using the react-native CLI to create a bare project then integrate react-native-firebase following all our documentation. The end result is an integration that works on iOS, every time. It may help you diagnose what went wrong with your integration if you compare the steps the scripts takes vs what you have done or not done -- https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

@grkemtneri
Copy link

Same issue, I was using react native 0.72.4 version without any problems, but when I upgraded to 0.77.1, this problem started to occur.

"@react-native-firebase/analytics": "18.6.1" to "21.12.0"
"@react-native-firebase/app": "18.6.1" to "21.12.0"
"@react-native-firebase/crashlytics": "18.6.1" to "21.12.0"
"@react-native-firebase/dynamic-links": "18.6.1" to "21.12.0"
"@react-native-firebase/messaging": "18.6.1" to "21.12.0"

 classpath("com.google.gms:google-services:4.4.0") to "4.4.2"
 classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'' to "3.0.3"

@mikehardy
Copy link
Collaborator

@grkemtneri same general solution if this is also on iOS like the OP (if it is not, you have a different problem) - carefully examine your AppDelegate implementation to make sure you are importing Firebase and that you call Firebase configure

@davortrifunov
Copy link

any updates ? Did anyone manage to find a solution?

@mikehardy
Copy link
Collaborator

@davortrifunov no one has posted what their AppDelegate implementation looks like, so there is no real information to go on - just a complaint that things aren't working - that's not enough to find a solution unfortunately

@nshutinicolas

This comment has been minimized.

@mikehardy
Copy link
Collaborator

If you are using the CLI then you are a perfect candidate for examining + comparing with your project the result of this https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

Just ran it this morning. Zero issues, starting from scratch with the CLI, on the versions you indicate. Not sure what is going on with your project without examining every bit of it unfortunately, and that's impractical given ratio of "people doing support" vs "people using react-native-firebase" - so checking the result of that "definitely works" build is the fastest way to resolution for you I think

@nshutinicolas
Copy link

Hey @mikehardy, thanks for the link, it took me a while to realize that I had to use xcode to move GoogleService-Info.plist file into the project.
I appreciate

How I wish there could update the documentation at https://rnfirebase.io/ to reflect the recent changes(moving from obj-c to swift)!

@mikehardy
Copy link
Collaborator

We'll have the update to the docs for swift soon - there's a PR lodged already

Really glad you found the underlying issue - if you saw the tricks I had to do in the script to automate the addition of that file 😆 - easier to do manually in fact, but then it wouldn't be a script. Cheers

@grkemtneri

This comment has been minimized.

@mikehardy

This comment has been minimized.

@mikehardy
Copy link
Collaborator

Docs for AppDelegate.swift have been integrated. I still reproduce no issues in my build reproducer.

Anyone still seeing this needs to very very very carefully examine their integration in the context of our installation documents, and/or consult my script at https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh (it has comments! they explain everything!) to make sure you have done everything.

If you get this error, you have integrated things incorrectly but it will most likely be specific to your project and the most likely response will be for you to run https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh and make sure it works - if it does, it's your project and you will have to find the problem, we can't find it for you as we do not have infinite time for project-specific troubleshooting

Thanks for your understanding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants