问题
I am working on Android Google Drive. As of now I am using the github sample code Android Demos. I am getting an error of
The import com.google.android.gms.drive.DriveApi.DriveContentsResult cannot be resolved
and
The import com.google.android.gms.drive.DriveContents cannot be resolved
I am using the updated Google play service and I have imported it properly.
I am using eclipse
回答1:
I remember using 'ContentsResult' in GooPlaySvcs 6.1.+ and switching to 'DriveContentsResult' after installing GooPlaySvcs 6.5.+, So, I'm assuming you have 6.1.+ or older. Correct GooPlaySvcs lib for 'DriveContentsResult' is '6.5.+', aka 'Rev. 22' in Android SDK Manager:
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'
}
....
....
}
It is also known as 'pulling the rug out (from under someone)'
Hope this helps.
回答2:
The import com.google.android.gms.drive.DriveApi.DriveContentsResult cannot be resolved
and
The import com.google.android.gms.drive.DriveContents cannot be resolved
This occur when we use old Google play service library and new code. Just delete the old library, download new Google play service library if you don't have and import the library to your workspace.
When you do like this, if you are using
import com.google.android.gms.drive.events.DriveEvent.Listener
Then change the line to
import com.google.android.gms.drive.events.ChangeListener;
Because Listener became ChangeListener in the new lib, and make corresponding changes in the code.
来源:https://stackoverflow.com/questions/28405205/error-com-google-android-gms-drive-driveapi-drivecontentsresult-cannot-be-resolv