微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何解决“未找到课程’com.google.android.gms.auth.GoogleAuthUtil’”错误?

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

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

线.

错误
“未在路径上找到”com.google.android.gms.auth.GoogleAuthUtil“类: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'
}

清洁和重建.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐