Android 访问Google凭据时出错
我有以下代码来使用OAUTH 2.0访问日历APIAndroid 访问Google凭据时出错,android,google-api,google-calendar-api,Android,Google Api,Google Calendar Api,我有以下代码来使用OAUTH 2.0访问日历API public static Calendar build(String accessToken) { HttpTransport transport = AndroidHttp.newCompatibleTransport(); JacksonFactory jsonFactory = new JacksonFactory(); httpRequestInitializer(credential); Log.i(
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;
}
当我运行代码时,应用程序强制关闭,logcat给我以下错误:
找不到从com.google.api.client.auth.oauth2.Credential方法引用的类“com.google.api.client.util.Clock”。
我试着改变一切,现在我不知道该怎么做 您需要在类路径中包含google http java客户端JAR 最新的google http java客户端可从以下位置获得:
我已经做过了,已经尝试过重做,但没有修复。然后我返回到使用以前版本的api,它不会抛出任何错误。仍然不知道是什么把它勾掉了谷歌文档和谷歌样本不再匹配了。它们完全不同步。从一个星期开始,我就尝试用当前的API获取一个工作示例。