1
votes

I have been getting this error on my project, so suspecting some change on firebase side I created a fresh new nativescript project, fresh new firebase project with fresh new android app, adding fresh database data, still getting the same error.

Essentially all firebase.instance inside nativescript-plugin-firebase plugin are null all of a sudden without any change in code from my side

Essentially all firebase.instance inside nativescript-plugin-firebase plugin are null all of a sudden without any change in code from my side.

Error Message Received on terminal:

JS: Error in firebase.addValueEventListener: TypeError: Cannot read property 'child' of null JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'child' of null JS: TypeError: Cannot read property 'child' of null JS: at file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/nativescript-plugin-firebase/firebase.js:1456:24 JS: at new ZoneAwarePromise (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:776:29) JS: at Object.firebase.addValueEventListener (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/nativescript-plugin-firebase/firebase.js:1444:10) JS: at Observable._subscribe (file:///data/data/org.nativescript.bbnsng/files/app/modules/services/firebase.service.js:23:22) JS: at Observable._trySubscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/Observable.js:57:25) JS: at Observable.subscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/Observable.js:45:27) JS: at Observable.ConnectableObservable.connect (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/observable/ConnectableObservable.js:37:18) JS: at RefCountOperator.call (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/observable/ConnectableObservable.js:101:49) JS: at Observable.subscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/Observable.js:42:22) JS: at ObservableStrategy.createSubscription (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/common/bundles/common.umd.js:2664:22) JS: at AsyncPipe._subscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/common/bundles/common.umd.js:2778:45) JS: at AsyncPipe.transform (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/common/bundles/common.umd.js:2755:22) JS: at Object.eval [as updateDirectives] (ng:///HomeModule/HomeComponent.ngfactory.js:127:68) JS: at Object.debugUpdateDirectives [as updateDirectives] (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/core/bundles/core.umd.js:12613:21) JS: at checkAndUpdateView (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/core/bundles/core.umd.js:12025:14)

Steps I followed:

  • Create a new repo
  • Create a new firebase project in firebase console
  • Create an android app under that probject with Package name org.nativescript.bbnsng
  • Run keytool -list -v -keystore ~/.android/bbnsng.keystore to get SHA1, update app with same
  • Add some data to database and make permission rules public
  • Code up the corresponsding nativescript angular app to this state https://github.com/ishandutta2007/bb_ns_ng_main_app2
  • downloaded google-services.json and add it to app/App_Resources/Android/
  • Run the app.

Steps to reproduce: git clone https://github.com/ishandutta2007/bb_ns_ng_main_app2.git cd bb_ns_ng_main_app2 tns run android

1

1 Answers

0
votes

For me, adding following statement to app.js/app.ts fixed this issue provided I have correct firebase database configured. For Example:

require("./shared/firebase/firebase.common");

For Angular Project, add import firebase.common in main.ts. For example:

import "./shared/firebase/firebase.common";