gpt4 book ai didi

android - 如何解决 "Didn' t find class 'com.google.android.gms.auth.GoogleAuthUtil'“错误?

转载 作者:太空宇宙 更新时间:2023-11-03 12:15:32 24 4
gpt4 key购买 nike

我第一次尝试在 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 (Module: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'
}

清理和重建。

关于android - 如何解决 "Didn' t find class 'com.google.android.gms.auth.GoogleAuthUtil'“错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37866058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com