DriveClient和DriveResourceClient总是抛出致命异常

时间:2018-10-08 12:46:48

标签: google-drive-api google-play-services google-api-java-client

我有一个成功的GoogleSignInAccount对象,并且我需要同时获得该帐户的DriveClient和DriveResourceClient,实际上我是以这种方式进行的:

GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);

if(account != null){

  DriveClient driveClient = Drive.getDriveClient(this,account);

  DriveResourceClient driveResourceClient = Drive.getDriveResourceClient(this,account);

}

但是,当我尝试执行以下简单任务时:

DriveFolder root = driveResourceClient.getRootFolder().getResult();

我收到此错误:

  

E / Android运行时:致命异常:主要       流程:com.myorg.myapp,PID:21980       java.lang.RuntimeException:无法启动活动ComponentInfo {com.myorg.myapp / com.myorg.myapp.DriveUpload2}:java.lang.IllegalStateException:任务尚未完成           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)           在android.app.ActivityThread.access $ 900(ActivityThread.java:150)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)           在android.os.Handler.dispatchMessage(Handler.java:102)           在android.os.Looper.loop(Looper.java:148)           在android.app.ActivityThread.main(ActivityThread.java:5417)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)        原因:java.lang.IllegalStateException:任务尚未完成           位于com.google.android.gms.common.internal.Preconditions.checkState(未知来源)           在com.google.android.gms.tasks.zzu.zzb(未知来源)           在com.google.android.gms.tasks.zzu.getResult(未知来源)           在com.myorg.myapp.DriveUpload2.signIn(DriveUpload2.java:94)           在com.myorg.myapp.DriveUpload2.onCreate(DriveUpload2.java:139)           在android.app.Activity.performCreate(Activity.java:6406)           在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)           在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)           在android.app.ActivityThread.access $ 900(ActivityThread.java:150)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344)           在android.os.Handler.dispatchMessage(Handler.java:102)           在android.os.Looper.loop(Looper.java:148)           在android.app.ActivityThread.main(ActivityThread.java:5417)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726)           com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

“ Google控制台凭据”页面上的所有范围配置均正确,并且在创建Drive.SCOPE_FILE时已经请求了必需的范围,例如Drive.SCOPE_APPFOLDERGoogleSignInOptions

0 个答案:

没有答案