Skip to content

Error in application initialization - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured #3685

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

Closed
2 of 10 tasks
aurelienmartin opened this issue May 25, 2020 · 15 comments

Comments

@aurelienmartin
Copy link

Issue

Hello,

I followed all the steps to install the library on React-Native but unable to complete the configuration of the project on the site https://console.firebase.google.com

Capture d’écran 2020-05-25 à 18 02 03

The following error appears in the console: [Firebase / Core] [I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure]; (FirebaseApp.configure () in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.

Capture d’écran 2020-05-25 à 18 06 47

I followed the guide to put the GoogleService file but the error persists. Is this a problem in the latest version of React Native Firebase ?

Thanks ! Aurélien


Project Files

Javascript

Click To Expand

package.json:

# N/A

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

def add_flipper_pods!(versions = {})
  versions['Flipper'] ||= '~> 0.33.1'
  versions['DoubleConversion'] ||= '1.1.7'
  versions['Flipper-Folly'] ||= '~> 2.1'
  versions['Flipper-Glog'] ||= '0.3.6'
  versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
  versions['Flipper-RSocket'] ||= '~> 1.0'

  pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug'

  # List all transitive dependencies for FlipperKit pods
  # to avoid them being linked in Release builds
  pod 'Flipper', versions['Flipper'], :configuration => 'Debug'
  pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug'
  pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug'
  pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug'
  pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug'
  pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug'
  pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
end

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end
  end
end

target 'Again' do
  # Pods for Again
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'AgainTests' do
    inherit! :complete
    # Pods for testing
  end

  use_native_modules!

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'Again-tvOS' do
  # Pods for Again-tvOS

  target 'Again-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

AppDelegate.m:

#import "AppDelegate.h"

#import <Firebase.h>
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#if DEBUG
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) {
  FlipperClient *client = [FlipperClient sharedClient];
  SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  [client addPlugin:[FlipperKitReactPlugin new]];
  [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  [client start];
}
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
#if DEBUG
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"Again"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end


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:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

2020-05-25 17:58:54.260396+0200 Again[6295:683862] 6.25.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
flipper: FlipperClient::addPlugin Inspector
flipper: FlipperClient::addPlugin Preferences
flipper: FlipperClient::addPlugin React
flipper: FlipperClient::addPlugin Network
flipper: FlipperClient::onConnected
  • Platform that you're experiencing the issue on:
    • 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:
    • 7.1.0
  • Firebase module(s) you're using that has the issue:
    • react-native-firebase/auth
  • Are you using TypeScript?
    • N


@mikehardy
Copy link
Collaborator

Something must have been missed. So many ways to do it wrong, very hard to say what was missed. Instead I will point to a script you can read that does it step by step - see if you can compare with your project to find whatever is missing: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

@ghasemikasra39
Copy link

Dear @aurelienmartin.
You may have issue. Firebase products give you this error, when you try to run your app on a Android/ios simulator/emulator, or even on real device connected with a cable, but again in dev mode. try to create a standalone apk/ipa app and install the app on your phone. See if the issue persists.

@ghasemikasra39
Copy link

ghasemikasra39 commented May 26, 2020

Dear @mikehardy
As @aurelienmartin mentoioned, I have a similar issue. I was not sure if I need to open a separate issue/ feature request for it.

I am using Firebase Crashlytics. Everything works fine on standalone app. However, during development, as soon as I have import crashlytics from '@react-native-firebase/crashlytics'; in my code, I get Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() error . I have to comment out all my firebase imports to get rid of this error, which is a headache.
I tired:

let crashlytics;
if (!__DEV__) {
  crashlytics = require('@react-native-firebase/crashlytics');
}

But the trick above did not work. With this trick, I did not get the error anymore. However the Crashlytics functionality stopped working on standalone apk.

I see this issue as a feature request.

@cool-debug
Copy link

Having the same issue as @ghasemikasra39, not @aurelienmartin. Any solution ?

@aurelienmartin
Copy link
Author

Dear @aurelienmartin.
You may have issue. Firebase products give you this error, when you try to run your app on a Android/ios simulator/emulator, or even on real device connected with a cable, but again in dev mode. try to create a standalone apk/ipa app and install the app on your phone. See if the issue persists.

Thank you for taking the time to share your experience. I tried to complete the validation process of the application with the Firebase console after having made an ipa build and executed on my iPhone but the last step of verification with the Firebase servers is still pending.

@mikehardy
Copy link
Collaborator

@ghasemikasra39 this is not expected behavior.

Step 1 is a minimal reproducible example. Maintainers aren't seeing this behavior, so we don't know.

Here is the start of creating a throwaway react-native-firebase app: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

Clone that repo. Run that script. Provide it the firebase init files (plist / json) for a throwaway project you make in your firebase console so you can play freely.

Reproduce the behavior with a simple change to the App.js, and we can see what's going on.

I can't reproduce it though, when I run that script it makes an app that says Crashlytics is available 🤷

@cloudratha
Copy link

I struggled with this for ages and not sure if my solution is correct.

I had only installed @react-native-firebase/app, and assumed that was enough to get the verification passed, which wouldn't happen.

I then installed @react-native-firebase/analytics which then passed the verification (from the simulator).

However in my logs I was still getting Firebase is not configured. So I just removed the if ([FIRApp defaultApp] == nil) { if statement from AppDelegate.m and just called [FIRApp configure]; directly (as per Firebase's installation recommendation).

@yoshifumi4423
Copy link

@cloudratha
I have same situation like this 6.25.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8., although my app still works.
I don't know I can ignore this warning message since my app is working.

Once I remove if, the warning message was gone.

However in my logs I was still getting Firebase is not configured. So I just removed the if ([FIRApp defaultApp] == nil) { if statement from AppDelegate.m and just called [FIRApp configure]; directly (as per Firebase's installation recommendation).

If didFinishLaunchingWithOptions in AppDelegate.m is called multiple times in app, deleting if is not good to solve this warning message.

@cloudratha
Copy link

@yoshifumi4423 if you are worried about removing the if statement. Keep it. The first time it’s called the error will appear. Then once configured it should be ok. The message is actually a log but just carries a heavy message that seems negative.

@russellwheatley
Copy link
Member

As @mikehardy mentioned, this will be erroneous setup on your part and is not a React Native Firebase bug.

@kalmahik
Copy link

I struggled with this for ages and not sure if my solution is correct.

I had only installed @react-native-firebase/app, and assumed that was enough to get the verification passed, which wouldn't happen.

I then installed @react-native-firebase/analytics which then passed the verification (from the simulator).

However in my logs I was still getting Firebase is not configured. So I just removed the if ([FIRApp defaultApp] == nil) { if statement from AppDelegate.m and just called [FIRApp configure]; directly (as per Firebase's installation recommendation).

You saved my day. But also I'd like to add:

  [FIRApp configure];
  [RNSplashScreen show];
  return YES;

I'm using Splascreen, and have to add it after the firebase config

@mikehardy
Copy link
Collaborator

@kalmahik do not under any circumstances use 'RNSplashScreen'

see crazycodeboy/react-native-splash-screen#289 (comment)

Convert to https://github.com/zoontek/react-native-bootsplash
It is maintained and does not have issues like the unmaintained react-native-splash-screen library
It even has a nifty command line tool to integrate it so migrating is easy https://github.com/zoontek/react-native-bootsplash#assets-generation

@kalmahik
Copy link

@kalmahik do not under any circumstances use 'RNSplashScreen'

see crazycodeboy/react-native-splash-screen#289 (comment)

Convert to https://github.com/zoontek/react-native-bootsplash
It is maintained and does not have issues like the unmaintained react-native-splash-screen library
It even has a nifty command line tool to integrate it so migrating is easy https://github.com/zoontek/react-native-bootsplash#assets-generation

thx man seems that I have to migrate from RNSplashScreen to bootsplash

@j3igzero
Copy link

@ghasemikasra39 this is not expected behavior.

Step 1 is a minimal reproducible example. Maintainers aren't seeing this behavior, so we don't know.

Here is the start of creating a throwaway react-native-firebase app: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

Clone that repo. Run that script. Provide it the firebase init files (plist / json) for a throwaway project you make in your firebase console so you can play freely.

Reproduce the behavior with a simple change to the App.js, and we can see what's going on.

I can't reproduce it though, when I run that script it makes an app that says Crashlytics is available 🤷

@mikehardy The link you mentioned gets "404 not found"

@mikehardy
Copy link
Collaborator

@j3igzero yeah - "v6" is now "normal" so I don't suffix it: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

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

No branches or pull requests

9 participants