Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法从我的android应用程序上载到google drive_Java_Android_Google App Engine_Google Drive Api - Fatal编程技术网

Java 无法从我的android应用程序上载到google drive

Java 无法从我的android应用程序上载到google drive,java,android,google-app-engine,google-drive-api,Java,Android,Google App Engine,Google Drive Api,我正在编写一个adroid应用程序,用于上传选定的图像 到用户的谷歌硬盘 我已经将代码从git克隆到另一台机器上,然后图像将不再上传 我得到一个com.google.android.gms.auth.GoogleAuthException:Unknown异常。但它在这里被抓住了: } catch (IOException e) { e.printStackTrace(); } if(fileContent.length()>5*1024*1024) {

我正在编写一个adroid应用程序,用于上传选定的图像

到用户的谷歌硬盘

我已经将代码从git克隆到另一台机器上,然后图像将不再上传

我得到一个
com.google.android.gms.auth.GoogleAuthException:Unknown
异常。但它在这里被抓住了:

 } catch (IOException e) {
          e.printStackTrace();
        }

if(fileContent.length()>5*1024*1024)
{
//文件大小超过5 MB时可恢复上载。
//检查链接:
// 1) https://code.google.com/p/google-api-java-client/source/browse/drive-cmdline-sample/src/main/java/com/google/api/services/samples/drive/cmdline/DriveSample.java?repo=samples&r=08555cd2a27be66dc97505e15c60853f47d84b5a
// 2) http://stackoverflow.com/questions/15970423/uploading-downloading-of-large-size-file-to-google-drive-giving-error
AbstractGoogleClientRequest insert=mDriveService.files().insert(正文,mediaContent);
MediaHttpUploader uploader=insert.getMediaHttpUploader();
uploader.setDirectUploadeEnabled(false);
setProgressListener(新文件uploadProgressListener());
destFile=(File)insert.execute();
}   
其他的
{
//否则,我们将使用不可恢复的上载,这对于小型上载是安全的。
destFile=mDriveService.files().insert(body,mediaContent.execute();
}
我可以检查和验证的任何提示(可能缺少库引用?)


我认为这是因为我从外部SD上传了一张图像,但即使我从本地电话SD中选择,它也会引发同样的异常

你确定你所安装的
body
mediaContent
都不是空的吗?已经检查过了。非空
      if(fileContent.length() > 5 * 1024 * 1024)
      {
          // Resumable Uploads when the file size exceeds a file size of 5 MB.
          // check link : 
          // 1) https://code.google.com/p/google-api-java-client/source/browse/drive-cmdline-sample/src/main/java/com/google/api/services/samples/drive/cmdline/DriveSample.java?repo=samples&r=08555cd2a27be66dc97505e15c60853f47d84b5a
          // 2) http://stackoverflow.com/questions/15970423/uploading-downloading-of-large-size-file-to-google-drive-giving-error

          AbstractGoogleClientRequest<File> insert = mDriveService.files().insert(body, mediaContent);
          MediaHttpUploader uploader = insert.getMediaHttpUploader();
          uploader.setDirectUploadEnabled(false);
          uploader.setProgressListener(new FileUploadProgressListener());
          destFile = (File) insert.execute();

      }   
      else
      {
          // Else we go by Non Resumable Uploads, which is safe for small uploads.
          destFile = mDriveService.files().insert(body, mediaContent).execute();
      }