我有以下代码使用OAUTH 2.0访问Calendar API。
public static Calendar build(String accessToken) {
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JacksonFactory jsonFactory = new JacksonFactory();
httpRequestInitializer(credential);
Log.i("Reached calendar builder", "Reached calendar builder");
GoogleCredential credential = new GoogleCredential();
Calendar service = new Calendar.Builder(transport, jsonFactory, credential)
.setApplicationName("Meetrbus/1.0")
.setHttpRequestInitializer(credential);
.setJsonHttpRequestInitializer(
new JsonHttpRequestInitializer() {
public void initialize(JsonHttpRequest request) {
CalendarRequest calendarRequest = (CalendarRequest) request;
// TODO: Get an API key from Google's APIs
// Console:
// https://code.google.com/apis/console.
calendarRequest
.setKey("API_ACCESS_KEY");
}
}).build();
return service;
}
当我运行代码时,app force关闭,logcat给我以下错误:
Could not find class 'com.google.api.client.util.Clock', referenced from method com.google.api.client.auth.oauth2.Credential.<init>
我已经尝试过改变一切,现在我没有任何关于做什么的线索!
答案 0 :(得分:0)
您需要在类路径中包含google-http-java-client jar。
最新的google-http-java-client可以从这里获得: http://code.google.com/p/google-http-java-client/downloads/list