我如何解决这个问题;没有';找不到类';com.google.android.gms.auth.GoogleAuthUtil'&引用;错误?

我如何解决这个问题;没有';找不到类';com.google.android.gms.auth.GoogleAuthUtil'&引用;错误?,android,google-calendar-api,Android,Google Calendar Api,我第一次尝试在Android Studio中使用Google Calendar API,这个类一旦到达目标就会崩溃 mService.events().insert("primary", event).execute(); 线路 错误说 在路径:DexPathList上未找到类“com.google.android.gms.auth.GoogleAuthUtil” 公共类CalendarRequestTask扩展了AsyncTask{ private com.google.api.servi

我第一次尝试在Android Studio中使用Google Calendar API,这个类一旦到达目标就会崩溃

mService.events().insert("primary", event).execute();
线路

错误说 在路径:DexPathList上未找到类“com.google.android.gms.auth.GoogleAuthUtil”


公共类CalendarRequestTask扩展了AsyncTask{
private com.google.api.services.calendar.calendar mService=null;
私有异常mLastError=null;
公共日历请求任务(GoogleAccountCredential凭据){
HttpTransport-transport=AndroidHttp.newCompatibleTransport();
JsonFactory JsonFactory=JacksonFactory.getDefaultInstance();
mService=new com.google.api.services.calendar.calendar.Builder(
运输、jsonFactory、凭证)
.setApplicationName(“任务跟踪器”)
.build();
}
/**
*后台任务调用谷歌日历API。
*@tasks包含事件的日期、标题和摘要。
*/
@凌驾
受保护的布尔doInBackground(任务…任务){
试一试{
setEventInApi(任务);
返回true;
}捕获(例外e){
mLastError=e;
取消(真);
返回false;
}
}
私有void setEventInApi(任务…任务)引发IOException{
//将事件插入谷歌日历
for(任务:任务){
事件=新事件()
.setSummary(task.getTitle())
.setDescription(task.getDescription());
DateTime startTime=新的日期时间(task.getDueDate());
EventDateTime开始=新的EventDateTime()
.setDateTime(开始时间);
event.setStart(启动);
mService.events().insert(“primary”,event.execute();
}
}
}
我解决了它

在app build.gradle中添加以下内容(模块:app)

在project build.gradle(项目:ProjectName)中添加以下内容


清理和重建

你解决问题了吗?我也面临同样的问题。
    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();
        }
    }
}
dependencies{
..
compile 'com.google.android.gms:play-services-auth:9.0.2'
}
dependencies {
classpath 'com.google.gms:google-services:1.5.0'
}