如何在谷歌驱动器上创建文件夹错误代码17 [解析被用户取消]

时间:2018-06-12 16:23:21

标签: android google-drive-android-api

我想将文件夹名称传递给我的函数并在我已登录的Google帐户中创建该文件夹

有我的SignInOptions

mGoogleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestScopes(new Scope(Scopes.DRIVE_FULL))
                    .requestScopes(Drive.SCOPE_FILE)
                    .requestScopes(Drive.SCOPE_APPFOLDER)
                    .requestEmail()
                    .build();
            mGoogleSignInClient = GoogleSignIn.getClient(this, mGoogleSignInOptions);
            account = GoogleSignIn.getLastSignedInAccount(this);

这是我的功能。

private void createFoler(String folderName) {
        mDriveResourceClient = Drive.getDriveResourceClient(this, account);
        mDriveResourceClient.getRootFolder()
                .continueWithTask(task -> {
                    DriveFolder parentFolder = task.getResult();
                    MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                            .setTitle(folderName)
                            .setMimeType(DriveFolder.MIME_TYPE)
                            .setStarred(true)
                            .build();
                    return mDriveResourceClient.createFolder(parentFolder, changeSet);
                });
    }

错误消息:

Unable to create file:com.google.android.gms.common.api.ApiException: 17: Error resolution was canceled by the user, original error message: INTERNAL_ERROR: null

我需要设置哪些配置?感谢

1 个答案:

答案 0 :(得分:0)

我认为这是由于范围所致,因为我看到您正在尝试Drive_Full

  

注意:Google Drive Android API当前仅支持drive.file和drive.appfolder授权范围。如果您的应用程序需要其他权限或Drive Android API中尚不可用的功能,则必须使用Google API Java Client。

您可以阅读更多here