Firebase init fails on android device
See original GitHub issueI 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:
- Created 7 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I too have encountered this problem. Here is how I solved it:
Hope my 2 cents helped!
@isaackwan Tnank you, this worked for me.