I have no idea where I went wrong, but following the link below and using the Google Documentation, I got nowhere.
https://www.numetriclabz.com/integrate-google-drive-in-android-tutorial/
And this piece of code seems to not work(Drive.API is not recognized):
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
I've added the API key and Google services version to the Manifest, but this website wont let me post it.
What's weird about this is that Google sign in worked like a charm.
GoogleSignInOptions gso = new
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /*
OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Which makes me really confused. On console.developers, I have google drive enabled. And in gradle I am importing google-services, so not importing Google Drive specifically, but I dont think that's the problem. Dont hesistate to ask me further questions or request screenshots.
In your module gradle,
For Gradle 3.0.+
dependencies {
implementation 'com.google.android.gms:play-services-drive:11.8.0'
}
For Gradle below 3.0:
dependencies {
compile 'com.google.android.gms:play-services-drive:11.8.0'
}
After that, the library will be ready. Then, import it with the following statement:
import com.google.android.gms.drive.Drive;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.