我有一个现有的应用程序,遗憾的是我没有时间在很长一段时间内更新它。我现在正在尝试做一些工作,但它不会编译。
它最初是一个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 ()函数找不到。
答案 0 :(得分:4)
要将评论(esp @kroikie)合并到答案中,您已经混淆了REST API的Java库(可以在Java / Android上运行,并由com.google.api.services.drive.Drive表示)使用适用于Android的Google Drive API(" GDAA" - 只需读取和写入Android上的云端硬盘存储区域,让Android云端硬盘应用进行同步,并由com.google.android.gms代表.drive.Drive)。
此人The method permissions() is undefined for the type Drive做了同样的事情,这表明Google文档未能明确指出有两种不同的方式可以实现Android-Drive集成。我已经看到人们将REST API称为"旧api",这是一个完全用词不当,并表明有些人已经得出GDAA取代了REST API,它肯定不会。
因此,在您的情况下,从您的应用中删除com.google.android.gms.*
,您就可以了。