Closed R-chie closed 2 years ago
Cleaning the project should fix you up ns clean
I have the same issue. ns clean didn't help. I try to init firebase in the app component with this.
import { firebase } from '@nativescript/firebase-core';
...
ngOnInit() {
firebase().initializeApp().then(
() => {
console.log("firebase.init done!");
},
error => {
console.log(firebase.init error: ${error}
);
}
);
}
anyone had the same issue and solved it?
You should call init outside of your app module
same issue here. Anyone find the fix ? share please.
async function initFireBase() {
try {
const defaultApp = await firebase().initializeApp();
} catch (err) {
console.log(err);
}
}
Console output
Successfully synced application org.nsf.mobileaudit on device RZ8N20KGVZE.
JS: Angular is running in development mode. Call enableProdMode() to enable production mode.
JS: ERROR Error: Uncaught (in promise): Error: Cannot read property 'initializeApp' of undefined
JS: Error: Cannot read property 'initializeApp' of undefined
JS: at file: src/webpack:/NSFAudit/node_modules/@nativescript/firebase-core/index.android.js:328:0
JS: at new ZoneAwarePromise (file: src/webpack:/NSFAudit/node_modules/zone.js/fesm2015/zone.js:1429:0)
JS: at Firebase.initializeApp (file: src/webpack:/NSFAudit/node_modules/@nativescript/firebase-core/index.android.js:267:0)
JS: at AppComponent.initifireBase (file: src/webpack:/NSFAudit/src/app/app.component.ts:85:0)
JS: at AppComponent.ngOnInit (file: src/webpack:/NSFAudit/src/app/app.component.ts:73:0)
JS: at callHook (file: src/webpack:/NSFAudit/node_modules/@angular/core/fesm2015/core.mjs:2491:0)
JS: at callHooks (file: src/webpack:/NSFAudit/node_modules/@angular/core/fesm2015/core.mjs:2460:0)
JS: at executeInitAndCheckHooks (file: src/webpack:/NSFAudit/node_modules/@angular/core/fesm2015/core.mjs:2411:0)
JS: at refreshView (file: src/webpack:/NSFAudit/node_modules/@angular/core/fesm2015/core.mjs:11979:0)
JS: at renderComponentOrTemplate
Error is here
Looks like FirebaseApp
is not a property of com.google.firebase
any update on this please ?
Can you try adding one of the optional modules e.g database or storage ?
Hi,
Same error here ; project cleaned, some other optional modules installed... No error on logcat (android), but same object FirebaseApp empty on firebase-core node_modules
@gyan-nsf @R-chie Have you found a solution since?
Thanks !
Hello,
I have the same issu firebase().initializeApp() is an Empty function, here is my package.json "dependencies": { "@angular/animations": "^12.2.5", "@angular/common": "^12.2.5", "@angular/compiler": "^12.2.5", "@angular/core": "^12.2.5", "@angular/forms": "^12.2.5", "@angular/platform-browser": "^12.2.5", "@angular/platform-browser-dynamic": "^12.2.5", "@angular/router": "^12.2.5", "@danvick/ngx-translate-nativescript-loader": "3.0.1", "@nativescript/angular": "^12.2.0", "@nativescript/core": "8.3.5", "@nativescript/email": "^2.0.5", "@nativescript/firebase": "^11.1.3", "@nativescript/secure-storage": "^3.0.0", "@nativescript/social-share": "^2.0.4", "@nativescript/theme": "~3.0.0", "@ngx-translate/core": "^13.0.0", "copyfiles": "^2.4.1", "nativescript-dna-deviceinfo": "^3.7.1", "nativescript-email": "^1.6.0", "nativescript-gtm": "^1.0.0", "nativescript-openurl": "^1.0.2", "nativescript-phone": "^3.0.1", "nativescript-social-share": "^1.6.0", "reflect-metadata": "~0.1.12", "rimraf": "^3.0.2", "rxjs": "~7.3.0", "zone.js": "~0.11.4" }
Anyone with only firebase-core installed will need to install one of the other firebase modules .eg storage.
Experiencing the same issue. firebase()
returns an empty object instead of firebase.
I have the following modules installed for firebase:
"@nativescript/firebase-core": "^2.3.4",
"@nativescript/firebase-crashlytics": "^2.3.4",
Hello @brysem , you will need to install "@nativescript/firebase-installations": "2.3.4", this will fix your issue
A couple things to try
Those getting the following error JS: ERROR Error: Uncaught (in promise): Error: Cannot read property 'initializeApp' of undefined
you need to install one of the other firebase packages
Those using any non vanilla flavor try calling the initializeApp in the app.(ts|js)/ main.ts early as possible
Hello @brysem , you will need to install "@nativescript/firebase-installations": "2.3.4", this will fix your issue
Thank you @aymenelhajayed. This solved my problem.
For anyone else running into the problem setting up crashlytics. I will leave the following below.
After installing the following three dependencies I have crashlytics working.
"@nativescript/firebase-core": "^2.3.4",
"@nativescript/firebase-crashlytics": "^2.3.4",
"@nativescript/firebase-installations": "^2.3.4",
I mounted firebase in main.ts
with the following code.
import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-crashlytics';
const firebaseApp = await firebase().initializeApp();
I can now use the log feature of crashlytics on the different pages in my app. Example:
import { firebase } from '@nativescript/firebase-core';
firebase().crashlytics().log('Login@mounted');
"@nativescript/firebase-core": "^2.2.9",
When i try to initialize firebase app, firebase() call doesn't return app instance
Can anyone explain what's wrong with that? Thanks
after watching problem deeper i got an exception after firebase().initializeApp() call