简体   繁体   English

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

[英]How can I resolve the “Didn't find class 'com.google.android.gms.auth.GoogleAuthUtil'” error?

I am trying to use the Google Calendar API for the first time in Android Studio, and this class is crashing once it gets to the 我想在Android Studio中第一次使用Google Calendar API,这个类一旦到达,就会崩溃

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

line. 线。

The error say "Didn't find class "com.google.android.gms.auth.GoogleAuthUtil" on path: DexPathList" 错误说“未找到类”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();
        }
    }
}

I solved it. 我解决了

Add the following in app build.gradle (Module:app) 在app build.gradle中添加以下内容(模块:app)

dependencies{
..
compile 'com.google.android.gms:play-services-auth:9.0.2'
}

Add the following in project build.gradle (Project:ProjectName) 在项目build.gradle中添加以下内容(Project:ProjectName)

dependencies {
classpath 'com.google.gms:google-services:1.5.0'
}

Clean and Rebuild. 清洁和重建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android找不到类“ com.google.android.gms.dynamic.DeferredLifecycleHelper”错误 - Android Didn't find class “com.google.android.gms.dynamic.DeferredLifecycleHelper” Error Android Google Play服务错误:在路径dexpathlist上找不到类com.google.android.gms.maps.mapfragment - Android Google Play Services error: didn't find class com.google.android.gms.maps.mapfragment on path dexpathlist 无法加载模块描述符类:找不到类“com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor” - Failed to load module descriptor class: Didn't find class “com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor” Android:在路径上找不到类“ com.google.android.gms.ads.AdActivity” - Android: Didn't find class “com.google.android.gms.ads.AdActivity” on path 谷歌地图没有找到类“com.google.android.gms.dynamic.zza” - Google Maps Didn't find class "com.google.android.gms.dynamic.zza" Java.lang.ClassNotFoundException:找不到类“ com.google.android.gms.dynamite.DynamiteModule $ DynamiteLoaderClassLoader” - Java.lang.ClassNotFoundException: Didn't find class “com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader” 找不到类“ com.google.android.gms.common.util.zzs” - Didn't find class “com.google.android.gms.common.util.zzs” 没有找到类“com.google.android.gms.ads.identifier.AdvertisingIdClient” - Didn't find class "com.google.android.gms.ads.identifier.AdvertisingIdClient" java.lang.ClassNotFoundException:在路径上找不到类“ com.google.android.gms.maps.SupportMapFragment” - java.lang.ClassNotFoundException: Didn't find class “com.google.android.gms.maps.SupportMapFragment” on path 由java.lang.ClassNotFoundException引起找不到类“ com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver - Caused by java.lang.ClassNotFoundException Didn't find class "com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM