gpt4 book ai didi

java - 无法从我的 Android 应用程序 com.google.android.gms.auth.GoogleAuthException : Unknown 上传到谷歌驱动器

转载 作者:行者123 更新时间:2023-11-30 11:23:55 29 4
gpt4 key购买 nike

我正在编写一个用于上传所选图像的 adroid 应用

到用户的谷歌驱动器。

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

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

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

enter image description here

      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();
}

这是我登录驱动代码

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

credential = GoogleAccountCredential.usingOAuth2(this, Collections.singleton(DriveScopes.DRIVE));
startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);

Intent intent = getIntent();

}

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
switch (requestCode) {
case REQUEST_ACCOUNT_PICKER:
if (resultCode == RESULT_OK && data != null && data.getExtras() != null) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) {
credential.setSelectedAccountName(accountName);
mDriveService = getDriveService(credential);
saveFileToDrive();
}
}
break;

//second try to upload, if credentials were wrong
case REQUEST_AUTHORIZATION:
if (resultCode == Activity.RESULT_OK) {
saveFileToDrive();
} else {
startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
}
break;
case CAPTURE_IMAGE:
if (resultCode == Activity.RESULT_OK) {
saveFileToDrive();
}
}
}

任何我可以检查和验证的提示(可能缺少库引用?)

我以为是因为我从外置SD上传图片,但即使我选择从本地手机SD也抛出同样的异常

最佳答案

问题是我必须重新注册我的应用

为创建和签署 apk 的新机器使用新的 SHA1 key

关于java - 无法从我的 Android 应用程序 com.google.android.gms.auth.GoogleAuthException : Unknown 上传到谷歌驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20913363/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com