Я пытаюсь получить все сообщения из Gmail с помощью GmailApi. Но когда я запускаю код, появляется эта ошибка.
"java .lang.RuntimeException: невозможно запустить действие ComponentInfo {com. yousefelsayed.myemail / com.yousefelsayed.myemail.MainActivity}: java .lang.IllegalArgumentException: имя не должно быть пустым: null"
И это говорит мне, что ошибка из этой строки
ListThreadsResponse listResponse = mService.users().threads().list("me").execute();
В чем проблема
MyCode:
mCredential = GoogleAccountCredential.usingOAuth2(
getApplicationContext(), SCOPES)
.setBackOff(new ExponentialBackOff());
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.gmail.Gmail.Builder(
transport, jsonFactory, mCredential)
.setApplicationName(getResources().getString(R.string.app_name))
.build();
try {
ListThreadsResponse listResponse = mService.users().threads().list("me").execute();
} catch (IOException e) {
e.printStackTrace();
}
Редактировать:
Полная ошибка:
05-28 09:15:39.836 22385-22385/com.yousefelsayed.myemail E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.yousefelsayed.myemail, PID: 22385
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yousefelsayed.myemail/com.yousefelsayed.myemail.MainActivity}: java.lang.IllegalArgumentException: the name must not be empty: null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2583)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1499)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5765)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by: java.lang.IllegalArgumentException: the name must not be empty: null
at android.accounts.Account.<init>(Account.java:48)
at com.google.android.gms.auth.zzg.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:267)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:292)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:880)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:542)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:475)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:592)
at com.yousefelsayed.myemail.MainActivity.onCreate(MainActivity.java:136)
at android.app.Activity.performCreate(Activity.java:6301)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2530)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1499)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5765)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
05-28 09: 15: 39.983 805-1769 /? E / Датчики: ручка handleToDriver (0)