最近,我有Android代码访问Google云端硬盘.我正在使用Google API Client Library for Java而不是Google Play服务客户端库
private static GoogleCloudFile searchFromGoogleDrive(Drive drive, String qString, HandleUserRecoverableAuthIOExceptionable h, PublishProgressable p) {
try {
Files.List request = drive.files().list().setQ(qString);
do {
if (p.isCancelled()) {
return null;
}
FileList fileList = request.execute();
Run Code Online (Sandbox Code Playgroud)
如果我使用,代码可以在几年内完成100%罚款targetSdkVersion 21.
最近,我将我的应用迁移到targetSdkVersion 23了Google Drive相关代码的0更改.
但是,代码崩溃了FileList fileList = request.execute();,但有以下异常.
Process: org.yccheok.jstock.gui, PID: 30317
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at …Run Code Online (Sandbox Code Playgroud) 我正在开发一个使用 Google Drive REST API 的 android 应用程序。我只想列出驱动器中的所有文件。但是当该方法listDriveFiles()被调用时,我得到一个错误为java.lang.IllegalArgumentException: the name must not be empty: null.
我发现这里提出了类似的问题,其中大多数都说要添加权限GET_ACCOUNT。我已经这样做了,但没有运气。一个答案指向检查 的值,getAccount()当我这样做时,我得到的值为null。
错误:
java.lang.IllegalArgumentException: the name must not be empty: null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5388)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:655)
at dalvik.system.NativeStart.main(Native Method)
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.zzd.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source) …Run Code Online (Sandbox Code Playgroud)