Ionic Angular GooglePlus:NgModule 的提供程序无效

Ionic Angular GooglePlus : Invalid provider for the NgModule

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

错误:

ERROR Error: Uncaught (in promise): Error: Invalid provider for the NgModule 'UsersModule' - only instances of Provider and Type are allowed, got: [Keyboard, ?[object Object]?]

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 授权工作所需的所有步骤。