com.google.android.gms.drive.DriveApi.ContentsResult cannot be resolved… But everything else can be?

℡╲_俬逩灬. 提交于 2019-12-11 20:14:56

问题


I'm getting this error:

 com.google.android.gms.drive.DriveApi.ContentsResult cannot be resolved

But just with that one import. These all work:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.drive.Contents;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveFile;
import com.google.android.gms.drive.DriveFolder.DriveFileResult;
import com.google.android.gms.drive.MetadataChangeSet;

And for some reason ContentsResult can't be found. Even doing this works:

 import com.google.android.gms.drive.DriveApi.*;

And it works in the sense that it doesn't error on the import, but when I do that, ContentsResult still just cannot be found...

Has anyone had this issue before?


回答1:


There is no ContentsResult class in the DriveApi package, but there is a DriveContentsResult class:

com.google.android.gms.drive.DriveApi.DriveContentsResult

See http://developer.android.com/reference/com/google/android/gms/drive/package-summary.html




回答2:


The answer 'myanimal' gave you is correct. You are probably using some older version of GDAA code, since 'ContentsResult' used to be there see here. Please make also sure you are compiling with the latest 'play-services:6.5.87'. I'm not sure it you are using Android Studio. If yes, see if your 'build.gradle' config file has the dependencies right:

dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  compile 'com.google.android.gms:play-services:6.5.87'
  compile 'com.google.apis:google-api-services-drive:v2-rev105-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'
  }
  ....
  ....
}

Disclaimer: It is not a 'better' answer, just an extension of "myanimal's" answer below.



来源:https://stackoverflow.com/questions/28254196/com-google-android-gms-drive-driveapi-contentsresult-cannot-be-resolved-but-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!