question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firebase init fails on android device

See original GitHub issue

I got the demo to work, but when adding this plugin to angular2-seed-advanced I keep getting this error:

JS: Error in firebase.init: TypeError: Cannot read property 'firebase' of undefined
JS: firebase.init error: TypeError: Cannot read property 'firebase' of undefined

Here’s my code:

// libs
import {Store} from '@ngrx/store';
// app
import {FormComponent} from '../../frameworks/core.framework/index';
import {NameListService} from '../../frameworks/app.framework/index';
var firebase = require('nativescript-plugin-firebase');
@FormComponent({
  selector: 'sd-home',
  templateUrl: './app/components/home/home.component.html',
  styleUrls: ['./app/components/home/home.component.css']
})
export class HomeComponent {
  public newName: string = '';
  public count: number = 0;
  constructor(private store: Store<any>, public nameListService: NameListService) {
    firebase.init({
      url: 'https://ng2-test-107d1.firebaseio.com/',
      persist: true
    }).then((instance: any) => {
      firebase.query((result: any) => {
        this.count = result.value;
      }, 'nativescript', { singleEvent: true });
    }, function (error: any) {
      console.log("firebase.init error: " + error);
    });
  }
  /*
   * @param newname  any text as input.
   * @returns return false to prevent default form submit behavior to refresh the page.
   */
  addName(): boolean {
    this.nameListService.add(this.newName);
    this.newName = '';
    return false;
  }
  addOne(): void {
    firebase.setValue('/nativescript', this.count++);
  }
}

What am I missing?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
isaackwancommented, May 31, 2016
1reaction
nikolalcommented, May 31, 2016

@isaackwan Tnank you, this worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot initialization options | Firebase - Google
To fix malfunctioning Firebase services for your applications: Update your application by initializing Firebase with a valid API key of your project, a...
Read more >
Android client FirebaseApp initialization error - Stack Overflow
Firebase SDK requires to have a "default" project configured via google-services.json. Once you have that you can register FCM sdk with ...
Read more >
Error in firebase.init: TypeError: Cannot read property ... - GitHub
init: TypeError: Cannot read property 'FirebaseAnalytics' of undefined LOG from device Fica cel: Angular is running in the development mode.
Read more >
Firebase initialize error - Android - Backendless Support
i solve it: i downgrade google-service version in build.gardle(project). that version was classpath 'com.google.gms:google-services:4.3.0 ...
Read more >
Android failed to initialize Firebase - Build issue - AppGyver
apk file directly to the device. In both cases, we are getting an error while trying to log in saying that Firebase is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found