EddyVerbruggen / nativescript-plugin-firebase

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

TypeError: Cannot read property 'FirebaseAuth' of undefined #1531

Open gambheera opened 4 years ago

gambheera commented 4 years ago

I'm trying to sign in with google account with angular, when I call the firebase.login function and getting following error:

google_sign_in_issue

This is my sign in function:

signInWithGoogle() {
        firebase.login({
            type: firebase.LoginType.GOOGLE,
            googleOptions: {
                hostedDomain: "mygsuitedomain.com",
                scopes: ['https://www.googleapis.com/auth/user.birthday.read']
            }
        }).then(
            function (result) {
                JSON.stringify(result);
            },
            function (errorMessage) {
                console.log(errorMessage);
            }
        );
    }

This is my init method. (This is called at the top of app.component)

firebase.init().then(
    (instance) => {
        console.log("[OK] FIREBASE.INIT: DONE", instance);
    },
    (error) => {
        console.log("[ERR] firebase.init error: ", error);
    }
);

this is my firebase.nativescript.json file:

{
    "using_ios": true,
    "using_android": true,
    "analytics": true,
    "firestore": false,
    "realtimedb": false,
    "authentication": true,
    "remote_config": false,
    "performance_monitoring": false,
    "external_push_client_only": false,
    "messaging": false,
    "in_app_messaging": false,
    "crashlytics": false,
    "storage": false,
    "functions": false,
    "facebook_auth": false,
    "google_auth": true,
    "admob": false,
    "dynamic_links": false,
    "ml_kit": false
}

This is my package.json file:

{
  "nativescript": {
    "id": "org.nativescript.loginExp6",
    "tns-android": {
      "version": "6.3.1"
    },
    "tns-ios": {
      "version": "6.3.0"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "lint": "tslint \"src/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@nativescript/theme": "~2.2.1",
    "nativescript-angular": "~8.20.3",
    "nativescript-plugin-firebase": "^10.3.3",
    "nativescript-ui-sidedrawer": "~8.0.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "~6.3.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.2.0",
    "@ngtools/webpack": "~8.2.0",
    "codelyzer": "~4.5.0",
    "nativescript-dev-webpack": "~1.4.0",
    "node-sass": "^4.7.1",
    "tslint": "~5.19.0",
    "typescript": "~3.5.3"
  },
  "gitHead": "fa98f785df3fba482e5e2a0c76f4be1fa6dc7a14",
  "readme": "NativeScript Application"
}

This functionality worked perfectly in nativescript-plugin-firebase version 6.0.2 with nativescript 4.0.1 And I have tried with removing android platform. But no luck

EddyVerbruggen commented 4 years ago

Are you using sidekick perhaps (because this plugin isn't supported by sidekick)? If not, can you share the project and the commands to run it?

gambheera commented 4 years ago

No I'm not using sidekick. Just _tns create --ng_

tns run android is the only command that I'm using to run the attached project. (I'm using windows 10) loginExp.zip

gambheera commented 4 years ago

@EddyVerbruggen I downgraded nativescript version to 6.0.2 and tested. Then I got following error

JS: Error in firebase.login: Error: android.content.res.Resources$NotFoundException: String resource ID #0x0
JS:     android.content.res.Resources.getText(Resources.java:367)
JS:     android.content.res.Resources.getString(Resources.java:460)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1109)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1089)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1081)
JS:     com.tns.gen.java.lang.Object_vendor_115452_32_ClickListenerImpl.onClick(Object_vendor_115452_32_ClickListenerImpl.java:18)
JS:     android.view.View.performClick(View.java:7201)
JS:     android.view.View.performClickInternal(View.java:7170)
JS:     android.view.View.access$3500(View.java:806)
JS:     android.view.View$PerformClick.run(View.java:27562)
JS:     android.os.Handler.handleCallback(Handler.java:883)
JS:     android.os.Handler.dispatchMessage(Handler.java:100)
JS:     an...
JS: Error: android.content.res.Resources$NotFoundException: String resource ID #0x0
JS:     android.content.res.Resources.getText(Resources.java:367)
JS:     android.content.res.Resources.getString(Resources.java:460)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1109)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1089)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1081)
JS:     com.tns.gen.java.lang.Object_vendor_115452_32_ClickListenerImpl.onClick(Object_vendor_115452_32_ClickListenerImpl.java:18)
JS:     android.view.View.performClick(View.java:7201)
JS:     android.view.View.performClickInternal(View.java:7170)
JS:     android.view.View.access$3500(View.java:806)
JS:     android.view.View$PerformClick.run(View.java:27562)
JS:     android.os.Handler.handleCallback(Handler.java:883)
JS:     android.os.Handler.dispatchMessage(Handler.java:100)
JS:     android.os.Looper.loop(Loop...

Seems like a compatibility issue. Could you suggest a nativescript-nativescript-plugin-firebase combination to solve this. Because this functionality worked perfectly in nativescript-plugin-firebase version 6.0.2 with nativescript 4.0.1

sido420 commented 3 years ago

I'm hitting the same issue. Any updates/workarounds?

R-chie commented 1 year ago

try to remove node_modules, platforms, then reinstall deps npm i