android - 在 Android 上继续使用旧的 Google Drive API

标签 android google-drive-api google-drive-android-api

我有一个现有的应用程序,不幸的是我已经很长时间没有时间更新它了。我现在正在尝试对它做一些工作,但它不会编译。

它最初是一个 Eclipse 项目,所以我现在将它导入到 Android Studio 中,我的 build.gradle 具有以下内容:

dependencies {
    /*compile 'com.google.android.gms:play-services-ads:7.0.0'
    compile 'com.google.android.gms:play-services-drive:7.0.0'
    compile 'com.google.android.gms:play-services-identity:7.0.0'*/
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/android-support-v4.jar')
    compile files('libs/commons-codec-1.4-javadoc.jar')
    compile files('libs/commons-codec-1.4-sources.jar')
    compile files('libs/commons-codec-1.4.jar')
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.BoardiesITSolutions:CritiMon:1.0'
    compile 'com.BoardiesITSolutions:Library:1.1'
    compile 'com.google.android.gms:play-services:4.1.+'
    compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
        exclude group: 'com.google.android.google-play-services'
    }
    compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
    compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
        exclude group: 'com.google.android.google-play-services'
    }
    compile 'com.google.apis:google-api-services-drive:v2+'
}

我试图将其指向旧版本的 Google Play 服务,下面的代码最初可以工作,但现在不再工作了。

Drive service = getDriveService(credential);

                    String fileId = null;
                    FileList file = service.files().list().execute();

问题是 services.files() 无法解决。

我假设这是因为 Drive API 正在更新,所以有没有办法让我可以使用支持上述代码的先前版本。

目前我没有时间更新 Drive API,但我需要修复某人报告的错误。

更新

我找到了以下 https://developers.google.com/drive/web/migration页面上说除了文件 ID 的变量名之外没有任何实际变化,但一切都是一样的,所以我不明白为什么找不到 service.files() 函数。

最佳答案

为了将评论 (esp @kroikie) 合并为一个答案,您混淆了 REST API 的 Java 库(它可以在 Java/Android 上运行,由 com.google.api.services.drive.Drive 表示)使用适用于 Android 的 Google Drive API(“GDAA” - 它只是读取和写入 Android 上的 Drive 存储区域,并让 Android Drive 应用程序进行同步,由 com.google.android.gms.drive.Drive 表示) .

这家伙 The method permissions() is undefined for the type Drive做了同样的事情,这表明谷歌文档未能明确说明有两种不同的方式可以实现 Android-Drive 集成。我看到人们将 REST API 称为“旧 API”,这完全是用词不当,这表明有些人得出了错误的结论,即 GDAA 取代了 REST API,但它肯定不会't.

因此,在您的情况下,从您的应用中删除 com.google.android.gms.* 就没问题了。

关于android - 在 Android 上继续使用旧的 Google Drive API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29190011/

相关文章:

android - 从 Drive 中的 sqlite 数据库读取并将其写入本地数据库 - Android

android - 快速滚动时 Universal Image Loader 崩溃

java - 如何通过url-request获取内容?

android - PhoneGap Android 项目中的多个 Html 文件

android - 如何在 Android 应用程序中显示来自 Google Drive 的照片?

android - 如何将文件夹中的选定文件从 Android 设备同步到 Google 云端硬盘,反之亦然

android - 如何在新的 Google Drive Android API 下切换帐户

android - Activity 布局 : Fragment class: vs android:name attributes

ios - 如何获取 iOS 中 Google 云端硬盘中文件夹的标识符?

android - Google Drive Android API (GDAA) getResourceId() 返回 null(计时问题)