nativescript-plugin-firebase icon indicating copy to clipboard operation
nativescript-plugin-firebase copied to clipboard

TypeError: Cannot read property 'FirebaseAuth' of undefined

Open gambheera opened this issue 5 years ago • 5 comments

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

gambheera avatar Jan 13 '20 15:01 gambheera

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?

EddyVerbruggen avatar Jan 14 '20 14:01 EddyVerbruggen

No I'm not using sidekick. Just tns create <app_name> --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 avatar Jan 14 '20 17:01 gambheera

@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

gambheera avatar Jan 18 '20 02:01 gambheera

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

sido420 avatar Mar 28 '21 12:03 sido420

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

R-chie avatar Oct 09 '22 14:10 R-chie