Ionic Angular GooglePlus:NgModule 的提供者无效

问题描述

我正在尝试使用 Angular 应用程序将 GooglePlus 登录集成到 Ionic。

错误

ERROR Error: Uncaught (in promise): Error: Invalid provider for the NgModule 'UsersModule' - 只有 Provider 和 Type 的实例是 允许,得到:[键盘,?[对象对象]?]

users.module.ts

...
import { GooglePlus } from '@ionic-native/google-plus';

@NgModule({
  declarations: [
    ...
  ],entryComponents: [
    ...
  ],imports: [
    ...
  ],exports: [
    ...
  ],providers: [
    ...,GooglePlus
  ]
})
export class UsersModule { }

解决方法

您需要将导入路径更改为:

import { GooglePlus } from '@ionic-native/google-plus/ngx';

您可能会看到构建错误:

An unhandled exception occurred: The target entry-point "@ionic-native/google-plus" has missing dependencies:
 - @ionic-native/core

只需安装 @ionic-native/core 依赖项即可。

npm install @ionic-native/core

最后一个想法,如果您在使用 Cordova 插件时遇到问题,另一个选项是 @codetrix-studio/capacitor-google-auth。 Simon Grimm 有一个很棒的博客 How to add Capacitor Google Sign In to your Ionic App,其中描述了让 Google 身份验证正常工作的所有必要步骤。