8
votes

I followed instructions from https://ionicframework.com/docs/native/google-plus/.

I've created Android Client in https://console.cloud.google.com/apis/credentials/oauthclient using correct SHA-1 (re-checked using keytool -list -printcert -jarfile <path to your apk>)

Code for login is simple as in instruction:

this.googlePlus.login({})
.then(res => console.log(res))
.catch(err => console.error(err));

However, it never comes into neither then nor catch. No error is displayed in console.

Ionic version 3.20.0

Cordova version 7.1.0

Ionic Native GooglePlus 5.3.0

Android phone version 5.1.1

cordova-plugin-googleplus 5.3.0

I've spent two days, Ionic Native Facebook is working fine, while GooglePlus is just failing silently.

Please advice.

UPDATE 1

It seems to be an issue with cordova-plugin-googleplus, as when I am changing GooglePlus.execute to use

@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    this.savedCallbackContext = callbackContext;
    savedCallbackContext.error(42);
    action = "abracadabra";
    ... //remains unchanged

then I see in Chrome console 42 - this means, that error handling is not working properly in the cordova-plugin-googleplus plugin.

9
Re-checked this.googlePlus.getSigningCertificateFingerprint - it returns correct value, which is set in Google Console for my android client. - heroin
can u try passing error call back to .then(res => console.log(res)) keep the catch as it is ? - Idrees Khan
Sorry, I am not sure I understand correctly. Do you mean .catch(err => console.log(err)); ? - heroin
no .then(res => console.log(res), error => console.log(error) - Idrees Khan
thanks, although no luck still - heroin

9 Answers

11
votes

Finally, the root cause and solution was found. The issue happened because Google updated all com.google.android.gms:play-* modules and this affected all Google services cordova plugins.

If you are using only Google Plus plugin, then everything should be fine I think.

In other case, all dependencies in project.properties, plugin.xml files to com.google.android.gms:play-* should be replaced with older version 11.8.0:

was

com.google.android.gms:play-services-auth:+

should be

com.google.android.gms:play-services-auth:11.8.0

I know, that this is better to be called a workaround, but no other solutions work.

Thanks guys from:

https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/492

https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/484

https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/488

UPDATE 08.10.2018

After last updates, plugin is again not working. The issue happened because of conflict of versions of ``com.google.android.gms:play-services-:`.

For instance, com.google.android.gms:play-services-maps:15.0.1, used by Google Maps plugin, and com.google.android.gms:play-services-auth:11.8.0 used by Google Plus plugin.

Solution is then straightforward:

  1. In config.xml put <variable name="PLAY_SERVICES_VERSION" value="15.0.1" /> (instead of 15.0.1 there could be newer/older version) to every plugin, which uses play services - normally all plugins related to Google services.
  2. In platforms/android/project.properties use everywhere for play services version 15.0.1 (here should version the same as in point 1).
5
votes

Thank you heroin for the answer. My problem was with:

1) com.google.android.gms:play-services-tagmanager:+

2) com.google.android.gms:play-services-auth:11.8.0

3) com.google.android.gms:play-services-identity:11.8.0

What I did to fix it was as heroin suggested, but instead I delete the 11.8.0 for 2) and 3) and just replaced it with the "+". Then I went into the config.xml found the:

variable name="PLAY_SERVICES_VERSION" value="11.8.0"

as heroin suggested, then replaced the "11.8.0" with "+". Re-compiled and ran, and now google plus works again.

3
votes

I tried to change the android/project.properties, the lines with google_auth and identity to

cordova.system.library.5=com.google.android.gms:play-services-auth:+ cordova.system.library.6=com.google.android.gms:play-services-identity:+

0
votes
I  used com.google.android.gms:play-services-auth:11.8.0 but still popup is not coming. No error. it never comes into neither then nor catch. No error is displayed in console.

Tried below code :

<code>
      if (this.platform.is('cordova')) {
        this.googlePlus.login({
          'scopes': '', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
          'webClientId': environment.googleWebClientId, // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
          'offline': true
        }).then((response) => {
          const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
          firebase.auth().signInWithCredential(googleCredential)
          .then(user => {
            console.log("Firebase success: " + JSON.stringify(user));
            resolve();
        });
        },(err) => {
         console.log("Error in doGoogleLogin " + err);
          reject(err);
        });
      }
</code>
0
votes

In my case same thing was happing and i tried almost 1 month and finally what worked for me is that i deleted my plugin folder and removed android platform and added it again. It worked for me. Hope it will help someone.

0
votes

in platforms>android>project.properties

change:

cordova.system.library.6=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.7=com.google.android.gms:play-services-identity:11.8.0

to:

cordova.system.library.6=com.google.android.gms:play-services-auth:+
cordova.system.library.7=com.google.android.gms:play-services-identity:+
0
votes

In my case I fixed it by changing the values from play services to be the same because using different versions cause some errors

So I change these values

"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"
      },

To

"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"
      },

And delete platforms, www and plugins folder and execute the "ionic cordova build android" command and it all works.

0
votes

i have the same issue with ionic 4.

the following change is fixed my issue :-----

before :

cordova.system.library.5=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.6=com.google.android.gms:play-services-identity:11.8.0

After :

cordova.system.library.5=com.google.android.gms:play-services-auth:15.0.1
cordova.system.library.6=com.google.android.gms:play-services-identity:15.0.1

you can find this settings on your "platform/android/project.properties" file.

0
votes

you must uninstall your plugin :

cordova plugin rm cordova-plugin-googleplus

and install again :

cordova plugin add cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=<you_reversed_client_id>

this worked for me.