通过 Google Drive Android API 迁移
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
云端硬盘 Android API 自 2018 年 12 月 6 日起已弃用,并将于 2023 年 2 月 1 日完全停用。
时间轴
日期 |
Drive Android API 状态 |
2018 年 12 月 6 日 |
弃用会公开发布。现有客户端将能够正常访问该 API,但应立即开始迁移工作。新客户不得使用该 API。
|
2019 年 10 月 21 日 |
已从 Google Play 服务 SDK 分发中移除 Drive Android API。在移除 Drive Android API 依赖项之前,应用将无法构建,但现有 build 不会受到影响。Drive Android API 公开文档将不再提供。
|
2022 年 3 月 3 日 |
云端硬盘 Android API 已被废弃,所有 API 调用均无法运行。客户必须在此日期之前完成迁移。
|
2023 年 2 月 1 日 |
云端硬盘 Android API 将完全停用,所有连接尝试都将失败。
|
使用 Drive REST API
云端硬盘 REST API 提供与云端硬盘 Android API 相同的功能,包括以下操作:
为了方便客户端迁移,我们提供了一个示例应用,其中演示了上述每项建议的替换。此外,它还展示了如何使用 REST API 创建、修改和查询用户的云端硬盘文件。如果您遇到任何问题,请查看 StackOverflow 上的 google-drive-api 标记。
迁移
由于 Drive Android API 已弃用,并且所有 API 调用均无法运行,请确保您的应用不再调用该 API。为此,请移除初始化 API 的代码:addApi(Drive.API)
。
如果您不从 Drive Android API 迁移,并且您的应用尝试调用该 API,系统会返回以下错误消息:
com.google.android.gms.common.api.ApiException: 17: API: Drive.API is not
available on this device. Connection failed with:
ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[],[],null,["# Migrate from the Google Drive Android API\n\n**The Drive Android API is deprecated as of December 6, 2018 and will be fully\nturned down on February 1, 2023**.\n\nTimeline\n--------\n\n| Date | Drive Android API status |\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| December 6, 2018 | Deprecation is [publicly announced](https://cloud.google.com/blog/products/application-development/sync-google-drive-files-to-apps-using-the-drive-rest-api-bidding-farewell-to-the-drive-android-api). Existing clients will be able to access the API normally, but should immediately commence with migration efforts. New clients must not use the API. |\n| October 21, 2019 | The Drive Android API is removed from the Google Play Services SDK distribution. Apps will be unable to build until removing the Drive Android API dependency, but existing builds will be unaffected. The Drive Android API public documentation will no longer be available. |\n| March 3, 2022 | The Drive Android API is deprecated and all API calls are non-operational. Clients must migrate by this date. |\n| February 1, 2023 | The Drive Android API will be fully turned down and all connection attempts will be unsuccessful. |\n\nUse the Drive REST API\n----------------------\n\nThe Drive REST API offers the same functionality as the Drive Android API,\nincluding ways to:\n\n- Share and collaborate as you expect from Drive. You can [manage permissions or prompt the Share dialog](/workspace/drive/api/guides/manage-sharing) to users as needed. The REST API also allows for commenting on files, allowing your app to interact with the conversation around a file.\n- Search for files using [`files.list`](/workspace/drive/api/v3/reference/files/list), based on traditional indexing or [your own customized, indexable text](/workspace/drive/api/guides/file).\n- Detect changes to files through the [Changes collection](/workspace/drive/api/v3/reference/changes) and to any shared with the user through [shared drives](/workspace/drive/api/guides/enable-shareddrives).\n- Export and convert Google Docs so that your app can easily [open a user's document](/workspace/drive/api/guides/integrate-open#specific).\n\nTo ease client migration efforts, a\n[sample app](https://github.com/googleworkspace/android-samples/tree/master/drive/deprecation) is provided which\ndemonstrates each of the proposed replacements above. It also shows how to\ncreate, modify, and query for a user's Drive files using the REST API. If you\nhave any issues, check out the\n[google-drive-api](https://stackoverflow.com/questions/tagged/google-drive-api?tab=Newest)\ntag on StackOverflow.\n\nMigration\n---------\n\nSince the Drive Android API is deprecated, and all API calls are\nnon-operational, make sure your app is no longer calling the API. To do this,\nremove the code that initializes the API: `addApi(Drive.API)`.\n\nIf you don't migrate from the Drive Android API, and your app attempts to call\nthe API, the following error message is returned:\n\n`com.google.android.gms.common.api.ApiException: 17: API: Drive.API is not\navailable on this device. Connection failed with:\nConnectionResult{statusCode=API_UNAVAILABLE, resolution=null, message=null}`"]]