2016-03-24 22 views
2

私はGoogleドライブに撮影した画像を保存しようとすると、私は次のエラーを取得する:不正な引数例外

java.lang.IllegalArgumentException: the name must not be empty: null 
           at android.accounts.Account.<init>(Account.java:48) 
           at com.google.android.gms.auth.zzd.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:255) 
           at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:279) 
           at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859) 
           at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) 
           at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) 
           at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460) 
           at com.amrutpatil.makeanote.GDActions.search(GDActions.java:290) 
           at com.amrutpatil.makeanote.GDActions.search(GDActions.java:211) 

私が正常にログインして上のフォルダを選択することができますGoogleドライブでは、画像を保存しようとすると、上記の問題が発生します。

Nexus 6物理デバイスで現在Marshmallowを実行しています。

マイGDActions.javaコード:

private static ArrayList<GF> search(ArrayList<GF> gfs, com.google.api.services.drive.Drive.Files.List qry) throws IOException { 
     String npTok = null; 
     if (qry != null) do { 
      FileList gLst = qry.execute(); //get an error here 
      if (gLst != null) { 
       for (File gFl : gLst.getItems()) { 
        if (gFl.getLabels().getTrashed()) continue; 
        gfs.add(new GF(gFl.getTitle(), gFl.getId())); 
       } 
       npTok = gLst.getNextPageToken(); 
       qry.setPageToken(npTok); 
      } 
     } while (npTok != null && npTok.length() > 0); 
     return gfs; 
    } 

私は上記のファイルリストgLst = qry.execute()でエラーが発生します。

検索方法がここに呼び出されたときにこれが起こる:

static ArrayList<GF> search(String prId, String titl, String mime) { 
     ArrayList<GF> gfs = new ArrayList<>(); 
     String qryClause = "'me' in owners and "; 
     if (prId != null) qryClause += "'" + prId + "' in parents and "; 
     if (titl != null) qryClause += "title = '" + titl + "' and "; 
     if (mime != null) qryClause += "mimeType = '" + mime + "' and "; 
     qryClause = qryClause.substring(0, qryClause.length() - " and ".length()); 
     com.google.api.services.drive.Drive.Files.List qry = null; 
     try { 
      qry = mGOOSvc.files().list().setQ(qryClause) 
        .setFields("items(id, labels/trashed, title), nextPageToken"); 
      gfs = search(gfs, qry); 
     } catch (GoogleAuthIOException gaiEx) { 
      try { 
       gfs = search(gfs, qry); //Invoked here 
      } catch (Exception g) { 
       GDUT.le(g); 
      } 
     } catch (Exception e) { 
      GDUT.le(e); 
     } 
     return gfs; 
    } 

答えて

0

java.lang.IllegalArgumentException: the name must not be empty: null

「名前」はアカウント名です。 GoogleAccountCredentialオブジェクトを設定していることを確認してください。

mAccountCredential.setSelectedAccountName("[email protected]"); 

注:完全な電子メールとしてアカウント名を設定します。 [email protected]の代わりに、user123の代わりに。

+0

私はあなたが提案したアカウント名を設定しようとしました。しかし、私は上記の同じエラーが発生し続けます。 – ap6491

0

権限の問題があることが判明しました。 AndroidManifest.xmlファイルにGET_ACCOUNTS権限が設定されていましたが、アプリの設定で連絡先権限を手動で有効にする必要がありました。

Android Marshmallow 6.0.1搭載のNexus 6物理デバイスでアプリを実行していたため、端末固有の問題が発生している可能性があります。

アプリの設定を安全に確認することができます。

関連する問題