![](/img/trans.png)
[英]Android Didn't find class “com.google.android.gms.dynamic.DeferredLifecycleHelper” Error
[英]How can I resolve the “Didn't find class 'com.google.android.gms.auth.GoogleAuthUtil'” error?
我想在Android Studio中第一次使用Google Calendar API,這個類一旦到達,就會崩潰
mService.events().insert("primary", event).execute();
線。
錯誤說“未找到類”com.google.android.gms.auth.GoogleAuthUtil“on path:DexPathList”
public class CalendarRequestTask extends AsyncTask<Task, Void, Boolean> {
private com.google.api.services.calendar.Calendar mService = null;
private Exception mLastError = null;
public CalendarRequestTask(GoogleAccountCredential credential) {
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.calendar.Calendar.Builder(
transport, jsonFactory, credential)
.setApplicationName("Task Tracker")
.build();
}
/**
* Background task to call Google Calendar API.
* @tasks has the date, title, summary of the event.
*/
@Override
protected Boolean doInBackground(Task... tasks) {
try {
setEventInApi(tasks);
return true;
} catch (Exception e) {
mLastError = e;
cancel(true);
return false;
}
}
private void setEventInApi(Task... tasks) throws IOException {
// Insert an event into the Google Calendar
for (Task task: tasks) {
Event event = new Event()
.setSummary(task.getTitle())
.setDescription(task.getDescription());
DateTime startTime = new DateTime(task.getDueDate());
EventDateTime start = new EventDateTime()
.setDateTime(startTime);
event.setStart(start);
mService.events().insert("primary", event).execute();
}
}
}
我解決了
在app build.gradle中添加以下內容(模塊:app)
dependencies{
..
compile 'com.google.android.gms:play-services-auth:9.0.2'
}
在項目build.gradle中添加以下內容(Project:ProjectName)
dependencies {
classpath 'com.google.gms:google-services:1.5.0'
}
清潔和重建。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.