2016-06-16 15 views
2

私は、Android Studioで初めてGoogleカレンダーのAPIを使用しようとしています、そしてそれは「クラス 'com.google.android.gms.auth.GoogleAuthUtil'」エラーが見つかりませんでしたか?

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

ラインに到達したら、このクラスがクラッシュしています。


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(); 
     } 
    } 
} 
+0

問題を解決しましたか?私は同じ問題に直面しています。 – TheOddAbhi

答えて

6

私はそれを解決:

エラーが が "DexPathListパスに "com.google.android.gms.auth.GoogleAuthUtil" クラスが見つかりませんでした" と言います。プロジェクトのbuild.gradleに(プロジェクト:プロジェクト名)以下を追加します

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

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

きれいにし、再構築します。

は、アプリのbuild.gradleに、次の(アプリモジュール)を追加します。

+0

問題が解決したら、回答を受け入れます。 – TheOddAbhi

関連する問題