首页 > 解决方案 > 使用 Ionic 4 和 Cordova 的 Google Plus 登录不起作用

问题描述

我正在使用 Ionic 4 实现 Google 登录。在上一个项目中,一切正常,但现在不起作用并给出任何错误。我不知道如何修复。

我尝试在工作时降级到与上一个项目相关的版本,但这会使项目无法编译。还尝试使用我的上一个项目,但是安装软件包时也不起作用。

{
  "name": "my_project",
  "version": "0.0.1",
  "author": "Stalin Maza",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.1.0",
    "@angular/common": "^7.2.2",
    "@angular/core": "^7.2.2",
    "@angular/forms": "^7.2.2",
    "@angular/http": "^7.2.2",
    "@angular/platform-browser": "^7.2.2",
    "@angular/platform-browser-dynamic": "^7.2.2",
    "@angular/router": "^7.2.2",
    "@ionic-native/android-permissions": "^5.9.0",
    "@ionic-native/camera": "^5.9.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/facebook": "^5.9.0",
    "@ionic-native/geolocation": "^5.8.0",
    "@ionic-native/google-plus": "5.6.0",
    "@ionic-native/in-app-browser": "^5.10.0",
    "@ionic-native/location-accuracy": "^5.9.0",
    "@ionic-native/native-storage": "^5.9.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.1.0",
    "@ionic/storage": "^2.2.0",
    "cordova-android": "8.0.0",
    "cordova-plugin-android-permissions": "^1.0.0",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-facebook4": "5.0.0",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-googleplus": "7.0.1",
    "cordova-plugin-inappbrowser": "^3.1.0",
    "cordova-plugin-nativestorage": "^2.3.2",
    "cordova-plugin-request-location-accuracy": "^2.3.0",
    "cordova-sqlite-storage": "^3.2.1",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "leaflet": "^1.5.1",
    "leaflet-gesture-handling": "^1.1.8",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.13.8",
    "@angular-devkit/build-angular": "~0.13.8",
    "@angular-devkit/core": "~7.3.8",
    "@angular-devkit/schematics": "~7.3.8",
    "@angular/cli": "~7.3.8",
    "@angular/compiler": "~7.2.2",
    "@angular/compiler-cli": "~7.2.2",
    "@angular/language-service": "~7.2.2",
    "@ionic/angular-toolkit": "~1.5.1",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~12.0.0",
    "codelyzer": "~4.5.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^4.1.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.3.0",
    "tslint": "~5.17.0",
    "typescript": "~3.1.6"
  },
  "description": "My PROJECT",
  "cordova": {
    "plugins": {
      "cordova-plugin-geolocation": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-android-permissions": {},
      "cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-nativestorage": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-googleplus": {
        "REVERSED_CLIENT_ID": "MY_REVERSED_ID",
        "PLAY_SERVICES_VERSION": "11.8.0"
      },
      "cordova-plugin-facebook4": {
        "APP_ID": "MY_APP_ID",
        "APP_NAME": "MY_APP_NAME",
        "FACEBOOK_HYBRID_APP_EVENTS": "false",
        "FACEBOOK_ANDROID_SDK_VERSION": "5.0.2"
      },
      "cordova-plugin-inappbrowser": {}
    },
    "platforms": [
      "android"
    ]
  }
}

我也使用 facebook 登录并解决任何问题,但谷歌无法正常工作

标签: cordovagoogle-plusionic4

解决方案


由于使用不同版本时会出现一些错误,因此使用 play serviced 版本中的相同版本解决了该问题。

所以我改变了这个值

"cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-googleplus": {
        "REVERSED_CLIENT_ID": "MY_REVERSED_ID",
        "PLAY_SERVICES_VERSION": "11.8.0"
      },

"cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "11.8.0"
      },
      "cordova-plugin-googleplus": {
        "REVERSED_CLIENT_ID": "MY_REVERSED_ID",
        "PLAY_SERVICES_VERSION": "11.8.0"
      },

并删除平台、www 和 plugins 文件夹并执行“ionic cordova build android”命令和所有工作


推荐阅读