Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Native GooglePlus login fails without any error

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.

like image 769
heroin Avatar asked May 09 '18 08:05

heroin


1 Answers

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).
like image 175
heroin Avatar answered Sep 18 '22 04:09

heroin