EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

App crashes after Firebase install on Geolocation #1494

Closed mturneruk closed 4 years ago

mturneruk commented 4 years ago

Hi - Any help much appreciated.

I have just installed the firebase plugin into our app for the purpose of delivering push Notifications.

On our signup page and other pages, we use another plugin Nativescript Geo-Location. (https://github.com/NativeScript/nativescript-geolocation) to get the users current location.

Before installing the Firebase plugin, the Geolocation plugin was working fine. However now the App crashes with no errors whenever i request the location.

                geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, maximumAge: 5000, timeout: 20000 }).then(geo => {

                    this.signupData.lat = String(geo.latitude);
                    this.signupData.lng = String(geo.longitude);
                });

I have tested this on both an Android Emulator and my Android Phone. I am initialising the firebase plugin in my app.component like this as per the docs.

        firebase.init({
          }).then(
            () => {
              console.log("firebase.init done");
            },
            error => {
              console.log(`firebase.init error: ${error}`);
            }
          );

Any help much appreciated. I have already asked on the NS Slack group and had no joy.

mturneruk commented 4 years ago

Found the answer to this problem.

Needed to create a before-plugins.gradle file in \App_Resources\Android\ with the following code in it.

android {  
  // other stuff here

  project.ext {
    googlePlayServicesVersion = "+"
  }
}

Cheers Martin