Open pranay-mathur opened 8 years ago
Hey @pranay-mathur, thanks for pointing this out.
I'm troubleshooting this issue right now. Can you answer a few questions?
Thanks! ~Sam
@sammuggPS
window.plugins.googleplus.isAvailable(function(available) { if (available) { window.plugins.googleplus.login({ 'offline': true, 'webClientId': '<webClientId>' }, function(obj) { console.log(JSON.stringify(obj)); }, function(msg) { alert('error: ' + msg); }); } });
(I added one more question before you responded, sorry. Refresh your page and check my original response)
@sammuggPS
I'm using a device, Sony Xperia Z2. I installed the plugin via https:// method.
I just recreated the issue! I apologize.
I'll get a hotfix deployed today. Thank you so much for bringing this to my attention! I'll respond again when I've pushed out the fix.
Thanks a lot @sammuggPS
Hey @pranay-mathur,
I just pushed the hotfix! Should be all set now. Why don't you give it another go and let me know where we stand. If this issue is resolved, please close it. If another issue arises, open it up and we'll work it out.
Thanks again for being awesome and bringing this to my attention!
Happy Coding, ~Sam
@sammuggPS
Thanks for the update, but it's still not working. The issue is with line no.129
String scopes = clientOptions.optString(ARGUMENT_SCOPES, null);
ARGUMENT_SCOPES value is null. Please check the attached screenshot.
@sammuggPS
Please fix this issue. I'm stuck with my android release.
@pranay-mathur please don't use words like 'ASAP' in an OSS repo. Thank you.
@EddyVerbruggen My humble apologies.. I'll be careful next time. Thank you for all work and support.
@pranay-mathur,
I'm pushed an update with some cleaned up code today, but I did not resolve the warning that you have shown here. I intentionally made the fallback value null.
If you look at the if
statement directly below, you'll notice that I am handling the cases of null or emptyString. A NullPointerException will not be thrown in this case. The same can be said for the webClientId, which is retrieved at line 123. Having the fallback value be null
allows us to more easily catch the case of no scopes passed in.
You may also notice that a NullPointerException warning occurs in the handleSignInResult method. This can also be confidently ignored because the JSONObject.put method allows null to be passed in as the Object value. You can read more about that method here.
Happy Coding! ~Sam
Hey @pranay-mathur, If you don't have any other questions or comments, can we go ahead and close this issue?
Best, ~Sam
@sammuggPS
Thanks again for the update. I installed the plugin using the https:// method, executed command cordova prepare and then cordova build android. While using the plugin, it's still giving the following error: -
E/PluginManager﹕ Uncaught exception from plugin java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.optString(java.lang.String, java.lang.String)' on a null object reference at nl.xservices.plugins.GooglePlus.buildGoogleApiClient(GooglePlus.java:118) at nl.xservices.plugins.GooglePlus.execute(GooglePlus.java:54) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:117) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98) at org.apache.cordova.PluginManager.exec(PluginManager.java:133) at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:37) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:211) at android.os.HandlerThread.run(HandlerThread.java:61)
Can you please tell me if I'm missing a step while installing the plugin.
@pranay-mathur,
What version of Java are you using? I've built using jdk 1.8 and jdk 1.7 and have not seen this issue.
Again, please make sure that your Android SDK Build-Tools, Android Platform Tools, and Android Support library are up to date.
@sammuggPS
I'm using JDK 1.8 and everything you mentioned are up to date.
@sammuggPS
The ARGUMENT_SCOPES and ARGUMENT_WEB_CLIENT_ID both are null from the start. That's why its throwing exception. But I don't understand why the parameters that I've provided are not available in the java code.
The function public boolean execute
has value of only one parameter i.e., action. The value of args is null.
@pranay-mathur,
Tell me more about your cordova set up:
Tell me more about your usage of the plugin:
Can you send me the output of your entire android build?
@sammuggPS
I'm not passing empty object as my first parameter in the plugin. I'm passing these as parameters
{ 'offline': true, 'webClientId': '<clientID>' }
. But they are not available in the java file. I have no issues in iOS build.
There are no issues in android build process.
Hi. Having a similar issue on Android. I was going through the plugin code and did not see a place where the REVERSED_CLIENT_ID was used for Android. So is this even neccessary?
I have installed the plugin with the following command:
cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --variable REVERSED_CLIENT_ID="MY_CLIENT_ID"
First i use the following code to either display the google login button or not:
$ionicPlatform.ready(function () { window.plugins.googleplus.isAvailable( function (available) { if (!available) { model.googleIsAvailable = false; } } ); });
When getting output from logcat i get the following when starting the app: run.txt
I use the following code to login: `window.plugins.googleplus.login({ webClientId: API.googleWebClientId }, function (success) {
var params = {
clientId: API.googleWebClientId
};
if(typeof success.serverAuthCode!== 'undefined'){
params.code = success.serverAuthCode;
}
if(typeof success.idToken!== 'undefined'){
params.access_token = success.idToken;
}
// Authenticate with our server
$http.post(API.baseUrl + '/auth/google', params).then(function (response) {
console.log(response);
deferred.resolve(response);
}, function (err) {
console.log('error with linking google api call', err);
deferred.reject(err);
});
}, function (err) {
console.log(err);
deferred.reject(err);
// throw err;
});`
The console outputs error with linking google api call 8
when trying to login
Logcat outputs the following: login.txt
@henritoivar, Your issue is not related to this one. Please open a separate ticket. Thanks!
I am having the same issue as this one. Same error message, parameters not empty but args.optJSONObject(0) is returning null so calling optString in a null object throws the error. Using latest versions and pulled code directly from git. It ran perfectly fine before but then I made a readded the plugins and this happened. @pranay-mathur were you able to resolve this?
Options from the plugin are not passed to the GooglePlus.java file.
{ 'offline': true, 'webClientId': '<clientID>' }
These are not passed to the native code and the plugin returns this error at the time of login: -
Uncaught exception from plugin java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.optString(java.lang.String, java.lang.String)' on a null object reference at nl.xservices.plugins.GooglePlus.buildGoogleApiClient(GooglePlus.java:129) at nl.xservices.plugins.GooglePlus.execute(GooglePlus.java:68) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:117) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98) at org.apache.cordova.PluginManager.exec(PluginManager.java:133) at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:37) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:211) at android.os.HandlerThread.run(HandlerThread.java:61)