App crashing when using Firebase Auth, reason: 'Default app has already been configured.'

firebase console
com firebase/core reason: 'default app has already been configured
unity firebase auth crash
firebase database
the default firebase app has not yet been configured
flutter default app has already been configured
firebase ios
firebase sdk download

I'm building my first iOS application, and I am using Firebase to handle authentication, database, etc. I added a sign up screen and used the following code to create a new user:

FIRAuth.auth()?.createUserWithEmail(emailAddress.text!, password: password.text!, completion: { (user, error) in

        })

When the user taps on the sign up button, there is a segue that should take them back to the original login view controller. However, when I got to run the app, it hangs on the launch screen. Here is the debugger output:

2016-06-19 14:35:05.402 unitaskr[4386:82981] Configuring the default app.
2016-06-19 14:35:05.413 unitaskr[4386:] <FIRAnalytics/INFO> Firebase Analytics     v.3200000 started
2016-06-19 14:35:05.414 unitaskr[4386:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...)
2016-06-19 14:35:05.419: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-19 14:35:05.418 unitaskr[4386:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-06-19 14:35:05.430 unitaskr[4386:82981] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Default app has already been configured.'
*** First throw call stack:
(
0   CoreFoundation                      0x00000001100a8d85   __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x00000001108e7deb objc_exception_throw + 48
2   CoreFoundation                      0x00000001100a8cbd +[NSException raise:format:] + 205
3   unitaskr                            0x000000010b58844d +[FIRApp    configureDefaultAppWithOptions:sendingNotifications:] + 102
4   unitaskr                            0x000000010b588238 +[FIRApp configure] + 302
5   unitaskr                            0x000000010b541f1a _TFC8unitaskr11AppDelegate11applicationfTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVs10DictionaryCSo8NSObjectPs9AnyObject____Sb + 266
6   unitaskr                            0x000000010b542204 _TToFC8unitaskr11AppDelegate11applicationfTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVs10DictionaryCSo8NSObjectPs9AnyObject____Sb + 180
7   UIKit                               0x000000010e5bf9ac -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
8   UIKit                               0x000000010e5c0c0d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
9   UIKit                               0x000000010e5c7568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
10  UIKit                               0x000000010e5c4714 -[UIApplication workspaceDidEndTransaction:] + 188
11  FrontBoardServices                  0x00000001127b78c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
12  FrontBoardServices                  0x00000001127b7741 -[FBSSerialQueue _performNext] + 178
13  FrontBoardServices                  0x00000001127b7aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
14  CoreFoundation                      0x000000010ffce301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15  CoreFoundation                      0x000000010ffc422c __CFRunLoopDoSources0 + 556
16  CoreFoundation                      0x000000010ffc36e3 __CFRunLoopRun + 867
17  CoreFoundation                      0x000000010ffc30f8 CFRunLoopRunSpecific + 488
18  UIKit                               0x000000010e5c3f21 -[UIApplication _run] + 402
19  UIKit                               0x000000010e5c8f09 UIApplicationMain + 171
20  unitaskr                            0x000000010b542a42 main + 114
21  libdyld.dylib                       0x00000001113b692d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

I can provide additional information as needed, any help/advice would be greatly appreciated as I am just starting out and looking to learn as much as possible. Have a great day!

I had a problem with a Messages Extension :

If you're in an App Extension, you have no delegate, and you'll have to put the FIRApp.configure() in the init of your main ViewController (or in the viewDidLoad as suggested).

Problem is : in a Messages Extension, if the user presses several messages in the thread opening your extension, init (or viewdidLoad) will be called several times, therefore crashing due to FIRApp.configure() called several times...

The solution I found was to create a static bool in the main View Controller :

    static var isAlreadyLaunchedOnce = false // Used to avoid 2 FIRApp configure

and I test it before calling FIRApp.configure() in the init or viewDidLoad :

// Configure Firebase
    // ------------------
    // We check if FIRApp has already been configured with a static var, else it will crash...
    if !MessagesViewController.isAlreadyLaunchedOnce {
        FIRApp.configure()

        MessagesViewController.isAlreadyLaunchedOnce = true
    }

This way, no more crashes.


Oh, I found a much more elegant way to solve the problem here : iOS Extension - Fatal Exception: com.firebase.core Default app has already been configured

    // Configure Firebase
    // ------------------
    if FIRApp.defaultApp() == nil {
        FIRApp.configure()            
    }

No more static this way ;)

App crashes after FirebaseAuth auth = FirebaseAuth , I use FireBase authentication with a simple function that signs up a shlighter changed the title App crashes after FirebaseAuth. How can I make Android Resolver to add it to my project, Why Isn't force resolve enough? In your Firebase Realtime Database and Cloud Storage Security Rules, you can get the signed-in user's unique user ID from the auth variable, and use it to control what data a user can access. You can allow users to sign in to your app using multiple authentication providers by linking auth provider credentials to an existing user account.

I wrote FIRApp.configure() twice, that seemed to fix the error.

Firebase Auth crash in Initialization step when running the app for , Firebase Auth crash in Initialization step when running the app for to find the root cause and potential patch to work-around with this issue. Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.

This is other solution about this issue. 1/ Check in the "AppDelegate.swift" we will see as below

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FirebaseApp.configure()
    return true
}

2/ Remove "FirebaseApp.configure()" from above code to

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    return true
}

3/ Add below code into "AppDelegate.swift"

override init() {
    FirebaseApp.configure()
}

4/ Go to "ViewController.swift" and add the code

    if FirebaseApp.app() == nil {
        FirebaseApp.configure()
    }

5/ Build again and Run it's will work. Thanks!

Firebase login causes crash?, I am having an issue with my Firebase login, user registration works fine, with below is my code for my firebase auth and also login/resiter button! does On which platforms (iOS and/or Android?) do you run into this issue? provider: ^4.0.2 firebase_core: ^0.4.4 firebase_auth: ^0.15.4 cloud_firestore: ^0.13.3 google_sign_in: ^4.1.4 Please follow the detailed instructions to integrate Firebase SDKs for both Android

You can call once in AppDelegate init method to configure.

override init() {
   // Firebase Init
   FIRApp.configure()
}

Customize your Firebase Crashlytics crash reports, Anonymous Authentication � Enabling cross-app authentication with shared iOS Custom keys help you get the specific state of your app leading up to a crash. You can associate arbitrary key/value pairs with your crash reports, and see them in the Incorrect usage of the recordError method can cause unpredicatable� Seamlessly authenticate with Firebase Authentication, then set up a chat room in the Realtime Database. Messages appear on all your users' devices in realtime. Use Firebase Cloud Messaging to send notifications so that your users get new messages if they're in another app.

Class Name: AppDelegate+FCMPlugin.m

[FIRApp.configure()];

Put this at the top most of this method

- (BOOL)application:(UIApplication *)application customDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 if(![FIRApp defaultApp]){
    [FIRApp configure];}}

Crash Reporting to help you prioritize and fix , Firebase Crashlytics is a crash reporter that helps you track, prioritize, and fix and troubleshooting crashes and more time building app features that delight users. With this insight, you can uncover the root cause of crashes more quickly . When signing in with GithubAuthProvider credentials with Firebase Auth, the app crashes on Android (stack trace below). This happens because info.getProfile() in mapFromAdditionalUserInfo() has JSONObject.NULL values, and JSONObject.NULL is not null, so the message codec does not detect it as a null. Most likely related to #37294. Stack trace:

App crashes after FirebaseAuth.DefaultInstance, I use FireBase authentication with a simple function that signs up a new user, it works Why do I even get the Firebase-AuthWeb-Exception ? Firebase/Play Services SDK version: 11.8.0; FirebaseUI version: 3.2.1; Step 2: Describe the problem: After integrating firebase ui, it works perfectly on my devices but i am getting app crashes on fabric and not sure why it is coming. I tried to look at the existing issues here but none of them resolved it. Observed Results: App crashed with

FirebaseAuth.getInstance() causing crash : Firebase, I feel so silly. i've spent the last week on the console trying to figure out why I kept I know GCP certifications do touch on using Firebase products but it would be bot which fetches live data from Firebase real-time database/Android app. For example, to increase your app's initial paint speed your app can first load Firebase Authentication. Then, when your app needs them, you can load other Firebase services, like Cloud Firestore. Using a package manager such as webpack, you can first load Firebase Authentication: import firebase from 'firebase/app'; import 'firebase/auth

App Crashes when tapping Sign up, I'm following along with the Firebase Authentication Tutorial 2019 - Custom iOS Login Page (Swift) tutorial on YouTube. For some reason, my app keeps crashing . You can specify how the Authentication state persists when using the Firebase JS SDK. This includes the ability to specify whether a signed in user should be indefinitely persisted until explicit sign out, cleared when the window is closed or cleared on page reload.

Comments
  • This is nice. Used it in an extension context.
  • Yes only downside is we get an annoying log about firebase isn't yet configured.
  • if FIRApp.defaultApp() == nil { FIRApp.configure() } worked for me, thanks!
  • I did the same thing accidentally and it threw the same error. You shouldn't have a problem anymore!
  • Thanks bro it's i did same misstake
  • Thanks man... same mistake here.
  • I'm calling this method in my extension keyboard class where I don't have AppDelegate class. so how should i do?
  • try to call this in your view controller viewDidLoad. override func viewDidLoad() { }
  • But thats the issue, because if I change my extension keyboard to native and native to extension then it crash and throwing same error.
  • can you make an extension of view controller and call their twice? and recheck
  • override func viewDidLoad() { super.viewDidLoad() FIRApp.configure() } //This I have written in my Keyboard extension UIInputViewController class. But when I switch my keyboard to Native ios keyboard and again to my keyboard this method is getting called and crash happen with this error- [reason: 'Default app has already been configured.']
  • This worked for me. But the thing is WHY? I am new to Flutter for iOS and this was bugging me from last night.