Gau-Yi / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Google Latitude API v1-json-oauth-sample fails with IllegalArgumentException #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Version of google-api-java-client (e.g. 1.3.1-alpha)?

1.3.1-alpha

Java environment (e.g. Java 6, Android 2.3, App Engine 1.4.2)?

Java 6

Describe the problem.

When retrieving the currentLocation, an HTTP response 200 is returned with the 
following content :

{ "data": {  "kind": "latitude#location",  "timestampMs": "1302281187688",  
"latitude": 44.3148443,  "longitude": -85.6023643 }}

When attempting to parse this (using 
request.execute().parseAs(LocationResource.class)), the following exception 
occurs

04-11 12:45:25.874: WARN/System.err(349): java.lang.IllegalArgumentException: 
null
04-11 12:45:25.894: WARN/System.err(349):     at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
04-11 12:45:25.924: WARN/System.err(349):     at 
com.google.api.client.json.JsonParser.startParsingObject(JsonParser.java:157)
04-11 12:45:25.944: WARN/System.err(349):     at 
com.google.api.client.json.JsonParser.skipToKey(JsonParser.java:132)
04-11 12:45:25.954: WARN/System.err(349):     at 
com.google.api.client.googleapis.json.JsonCParser.parserForResponse(JsonCParser.
java:83)
04-11 12:45:25.974: WARN/System.err(349):     at 
com.google.api.client.googleapis.json.JsonCParser.parse(JsonCParser.java:49)
04-11 12:45:25.984: WARN/System.err(349):     at 
com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:261)
04-11 12:45:25.994: WARN/System.err(349):     at 
com.google.api.client.sample.latitude.model.LocationResource.executeGetCurrentLo
cation(LocationResource.java:85)
04-11 12:45:26.004: WARN/System.err(349):     at 
com.ecs.android.sample.oauth.google.api.java.client.AndroidOauthGoogleApiJavaCli
ent.showCurrentLocation(AndroidOauthGoogleApiJavaClient.java:94)
04-11 12:45:26.014: WARN/System.err(349):     at 
com.ecs.android.sample.oauth.google.api.java.client.AndroidOauthGoogleApiJavaCli
ent.performApiCall(AndroidOauthGoogleApiJavaClient.java:70)
04-11 12:45:26.024: WARN/System.err(349):     at 
com.ecs.android.sample.oauth.google.api.java.client.AndroidOauthGoogleApiJavaCli
ent.onCreate(AndroidOauthGoogleApiJavaClient.java:55)
04-11 12:45:26.034: WARN/System.err(349):     at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 12:45:26.034: WARN/System.err(349):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-11 12:45:26.054: WARN/System.err(349):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-11 12:45:26.064: WARN/System.err(349):     at 
android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-11 12:45:26.074: WARN/System.err(349):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-11 12:45:26.084: WARN/System.err(349):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
04-11 12:45:26.084: WARN/System.err(349):     at 
android.os.Looper.loop(Looper.java:123)
04-11 12:45:26.094: WARN/System.err(349):     at 
android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 12:45:26.104: WARN/System.err(349):     at 
java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:45:26.114: WARN/System.err(349):     at 
java.lang.reflect.Method.invoke(Method.java:521)
04-11 12:45:26.114: WARN/System.err(349):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 12:45:26.124: WARN/System.err(349):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 12:45:26.134: WARN/System.err(349):     at 
dalvik.system.NativeStart.main(Native Method)

How would you expect it to be fixed?

Shouldn't throw an exception, as an HTTP 200 response was returned from the 
Latitude API.

Original issue reported on code.google.com by ddewa...@gmail.com on 11 Apr 2011 at 1:03

GoogleCodeExporter commented 9 years ago
I'm hitting the same issue. I'm just following the "Instructions for the Google 
Latitude API JSON OAuth Sample" at 
http://samples.google-api-java-client.googlecode.com/hg/latitude-json-oauth-samp
le/instructions.html?r=default and I'm getting this exception even though the 
HttpResponse looks correct

Original comment by pe...@heitman.us on 27 Apr 2011 at 6:01

GoogleCodeExporter commented 9 years ago
Should be fixed already.  Latitude sample runs okay now.

Original comment by yan...@google.com on 16 Aug 2011 at 2:43

GoogleCodeExporter commented 9 years ago
I'm hitting the same issue as well. Code was synched today (8/20/2011). 

Original comment by singam.s...@gmail.com on 20 Aug 2011 at 5:09

GoogleCodeExporter commented 9 years ago
I'm having the same problem. Checked out today.

Original comment by michael....@gmail.com on 30 Aug 2011 at 8:46

GoogleCodeExporter commented 9 years ago
.. but works if I change the type of LocationResource.timestampMs to String.

Original comment by michael....@gmail.com on 30 Aug 2011 at 8:51

GoogleCodeExporter commented 9 years ago
try the google-api-services-latitude-v1-1.1.0-beta.jar and 
google-api-client-1.4.1-beta.jar combo. There it got fixed.

Original comment by ddewa...@gmail.com on 30 Aug 2011 at 8:58