firebase icon indicating copy to clipboard operation
firebase copied to clipboard

[firebase-core]: Unable to Initialize Firebase App

Open kyao-Frndz opened this issue 3 years ago • 3 comments
trafficstars

Hello Team, Can you assist with the error below, when trying to initialize the firebase app from the firebase-core? Here is how I am initializing it

export class AppComponent implements OnInit {

    ngOnInit(): void {
        firebase().initializeApp().then((app) => {
            console.log(app);
        })
    }

}

Here is the error that shows up

JS: Error: Cannot read property 'FirebaseApp' of undefined
JS:     at file: src/webpack:/testapp/node_modules/@nativescript/firebase-core/index.android.js:295:0
JS:     at new ZoneAwarePromise (file: src/webpack:/testapp/node_modules/zone.js/fesm2015/zone.js:1429:0)
JS:     at Firebase.initializeApp (file: src/webpack:/testapp/node_modules/@nativescript/firebase-core/index.android.js:234:0)
JS:     at AppComponent.ngOnInit (file: src/webpack:/testapp/src/app/app.component.ts:6:16)
JS:     at callHook (file: src/webpack:/testapp/node_modules/@angular/core/fesm2015/core.mjs:2491:0)
JS:     at callHooks (file: src/webpack:/testapp/node_modules/@angular/core/fesm2015/core.mjs:2460:0)
JS:     at executeInitAndCheckHooks (file: src/webpack:/testapp/node_modules/@angular/core/fesm2015/core.mjs:2411:0)
JS:     at refreshView (file: src/webpack:/testapp/node_modules/@angular/core/fesm2015/core.mjs:11971:0)
JS:     at detectChangesInternal (file: src/webpack:/testapp/node_modules/@angular/core/fesm2015/core.mjs:13174:0)
JS:     at RootViewRef.detectChanges (file:///data/data/org.nativescript.testapp/fi...

kyao-Frndz avatar Nov 07 '22 15:11 kyao-Frndz

Can you try installing one of the other firebase packages e.g firebase-analytics

triniwiz avatar Nov 07 '22 18:11 triniwiz

hello, Something similar happens to me, not the same error but in the same initalizeApp().

ERROR:

Unhandled Promise rejection: Default app has already been configured. ; Zone: <root> ; Task: Promise.then ; Value: Error: Default app has already been configured. Error: Default app has already been configured. at initApp (file: node_modules/@nativescript/firebase-core/index.ios.js:393:0) at file: node_modules/@nativescript/firebase-core/index.ios.js:402:0 at new ZoneAwarePromise (file: node_modules/zone.js/fesm2015/zone.js:1429:0) at Firebase.initializeApp (file: node_modules/@nativescript/firebase-core/index.ios.js:312:0) at Module../app/main.ts (file: app/main.ts:9:0) at __webpack_require__ (file: app/webpack/bootstrap:24:0) at Object._requireSelf [as require] (file: app/webpack/runtime/hot module replacement:102:0) at Object.apply (file: app/webpack/runtime/require chunk loading:401:0) at file: app/webpack/runtime/hot module replacement:344:0 at Array.forEach (<anonymous>)

MacBook Pro M1 package.json: "@nativescript/core": "~8.3.4", "@nativescript/datetimepicker": "~2.1.11", "@nativescript/firebase": "~11.1.3", "@nativescript/firebase-core": "~2.3.4", "@nativescript/firebase-messaging": "~2.3.4",

Ederagp avatar Dec 09 '22 17:12 Ederagp

You need to remove @nativescript/firebase

triniwiz avatar Dec 12 '22 18:12 triniwiz