修复谷歌api java样本的纬度任何人吗?

时间:2011-05-21 14:02:59

标签: java google-api

我刚检查了google-api-java-client示例并使用eclipse maven构建它们。

我使用消费者密钥,消费者密钥和输入密钥定制了我的ClientCredentials类。

当我运行示例时,它会要求我授权访问我的谷歌纬度数据并关闭浏览器,并且eclipse控制台会出现此错误:

2011-05-21 23:57:01.777:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2011-05-21 23:57:01.778:INFO::jetty-6.1.24
2011-05-21 23:57:01.792:INFO::Started SocketConnector@localhost:51514
Created new window in existing browser session.
2011-05-21 23:57:09.121:INFO::Stopped SocketConnector@localhost:51514
Current location:
java.lang.IllegalArgumentException
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:72)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:450)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:249)
    at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:176)
    at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:115)
    at com.google.api.client.googleapis.json.JsonCParser.parse(JsonCParser.java:49)
    at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:261)
    at com.google.api.client.sample.latitude.model.LocationResource.executeGetCurrentLocation(LocationResource.java:78)
    at com.google.api.client.sample.latitude.LatitudeSample.showCurrentLocation(LatitudeSample.java:50)
    at com.google.api.client.sample.latitude.LatitudeSample.main(LatitudeSample.java:34)

当我调试应用程序时,这些是JsonParser.class第450行的变量:

newInstance null    
isMap   false   
token   JsonToken  (id=40)  
name    "VALUE_STRING" (id=55)  
ordinal 5   
field   Field  (id=45)  
fieldClass  Class<T> (java.lang.Long) (id=47)   

字段是:

public java.lang.Long com.google.api.client.sample.latitude.model.LocationResource.timestampMs

这是HG摘要:

bob@computer:~/development/google-api-java-client-samples$ hg summary
parent: 92:4be51d2cc385 tip
 Samples for version 1.4.
branch: default
commit: 1 modified
update: (current)

更新<!/强> 这可以通过从“public Long timestampMs”更改com.google.api.client.sample.latitude.model.LocationResource第30行来解决。 to“public String timestampMs;”。由于服务器发回的字符串不是数字。

真正的问题是:为什么服务器在样本需要数字时发回一个字符串?示例代码是错误的吗? (可能)或服务器?

0 个答案:

没有答案