This is a migrated thread and some comments may be shown as answers.

Nativescript Firebase plugin - “cannot read property of null” after upgrade to NS 3.4.0

2 Answers 328 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anurag
Top achievements
Rank 1
Anurag asked on 25 Dec 2017, 06:11 AM

My angular - Nativescript project uses the Nativescript-Firebase-Plugin. It works perfectly well in Nativescript 3.3
I upgraded my project to Nativescript 3.4. After upgrading the project, I am facing a major issue with all firebase queries.

**JS: Error in firebase.query: TypeError: Cannot read property 'child' of null** JS: NO QUESTIONS FOR THIS USER JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'length' of undefined JS: TypeError: Cannot read property 'length' of undefined JS:     at file:///data/data/org.nativescript.qbank/files/app/feed/alphaCreate.component.js:55:23JS:     at SafeSubscriber.schedulerFn [as _next] (file:///data/data/org.nativescript.qbank/files/app/tns_modules/@angular/core/bundles/core.umd.js:3870:36) JS:     at SafeSubscriber.__tryOrUnsub (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:238:16) JS:     at SafeSubscriber.next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:185:22) JS:     at Subscriber._next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:125:26) JS:     at Subscriber.next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:89:18) JS:     at EventEmitter.Subject.next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subject.js:55:25) JS:     at EventEmitter.emit (file:///data/data/org.nativescript.qbank/files/app/tns_modules/@angular/core/bundles/core.umd.js:3844:76) JS:     at file:///data/data/org.nativescript.qbank/files/app/services/my-questions.service.js:51:42JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:365:26) JS:     at Object.onInvoke (file:///data/data/org.nativescript.qbank/files/app/tns_modules/@angular/core/bundles/core.umd.js:4156:37) JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:364:32) JS:     at Zone.run (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:125:43) JS:     at file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:760:57JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31)

 

I tried to resolve it by
a. upgrading the native script firebase plugin: 5.0.5
b. upgrading all the dependenices of the project
But the issue is still occurring. This is a big blocker, and Please suggest what I can do to fix this.

My package json is as below:

{
  "android": {
    "markingMode": "none"
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.qbank",
    "tns-ios": {
      "version": "3.4.0"
    },
    "tns-android": {
      "version": "3.4.0"
    }
  },
  "dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/router": "~5.0.0",
    "nativescript-algolia": "0.0.4",
    "nativescript-angular": "~5.0.0",
    "nativescript-camera": "^3.1.4",
    "nativescript-email": "^1.5.1",
    "nativescript-fancyalert": "^1.1.2",
    "nativescript-filter-select": "^1.2.1",
    "nativescript-geolocation": "^3.0.0",
    "nativescript-gif": "^1.0.9",
    "nativescript-imagepicker": "^4.0.1",
    "nativescript-iqkeyboardmanager": "^1.1.0",
    "nativescript-loading-indicator": "^2.3.2",
    "nativescript-plugin-firebase": "^5.0.5",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "^1.4.5",
    "nativescript-web-image-cache": "^4.2.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^5.5.0",
    "tns-core-modules": "^3.4.0"
  },
  "devDependencies": {
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "codelyzer": "~4.0.2",
    "es6-promise-loader": "^1.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "^0.6.0",
    "tslint": "^5.1.0",
    "typescript": "~2.4.2",
    "zone.js": "^0.8.4"
  }
}

2 Answers, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 26 Dec 2017, 10:30 AM
Hi Anurag,

I have migrated the demo application created by Eddy Verbruggen (the author of nativescript-plugin-firebase) to the latest NativeScript 3.4.x 
and everything seems to works as expected with Firebase Realtime DB and Firestore (guessing that you are making queries to one of the two options as it was not explicitly clear based on the information provided in the ticket). Here you can find the migrated demo project for Angular - notice that if you want to test the demo project
with your own Firebase Console you will need to provide yours google-services.json here and change the package ID here and here before building the project.
With the above changes and the project build for Android, all queries to Realtime DB and Firestore are made and are successful.

Please note that the issue seems to be related to a specific part of your code located in alphaCreate.component.ts file so you might want to provide this part of the code or even a working sample project that can demonstrate the issue so that the issue could be reproduced and investigated further. Post the additional information in the logged issue where the author and other NativeScript members can guide you through what could be causing this issue.

As the issue is related to nativescript-plugin-firebase and custom code that works with that plugin please notice that you will receive faster and better advice on how to resolve the issue in the community channels and the repository of the plugin. The support for third-party libraries is not part of the Telerik Platform support or part of the NativeScript framework support. Please post any further information on the logged issue here or in the community channels like discourse.nativescript.org where you would receive help from other NativeScript members and community users.

Regards,
Nikolay Iliev
Progress Telerik
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Anurag
Top achievements
Rank 1
answered on 27 Dec 2017, 12:37 PM

Thanks for your response Nikolay. Will try out the demo app and see if I can get any pointers to what might be causing the issue.

Best

Anurag

Tags
General Discussion
Asked by
Anurag
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Anurag
Top achievements
Rank 1
Share this question
or