I'm trying to implement Google Drive to my Android app and I cannot even connect to Api client. And I don't know why:
onConnectionFailed()
I'm calling connectionResult.startResolutionForResult()
if connectionResult.hasResolution()
onActivityResult
for matching requestCode
I'm receiving resultCode == 0
(RESULT_CANCELLED) even when i select my accountDo you have any idea why? I also tried to add:
<meta-data
android:name="com.google.android.apps.drive.APP_ID"
android:value="----"/>
into Manifest which is not mentioned on documentation page but on some SO posts.
Thanks for help
Edit:
I have also tried to use enableAutoManage
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.build();
instead of manualy configuring connection and connectionFailed callbacks:
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
It returns me error code 13 in onConnectionFailed
method. Based on documentation it seems, that this returns when:
OnConnectionFailedListener passed to enableAutoManage(FragmentActivity, GoogleApiClient.OnConnectionFailedListener) when the user choses not to complete a provided resolution. For example by canceling a dialog.
But i didn't cancelled it.
I'm testing it on Nexus 5x - Android N
I found where the problem was while reading something about wallet api
I've just needed to create OAuth client ID not API key
Now it works!
JUST IN CASE
@VizGhar solution is right if you missed up Client ID creation process. But I get resultCode=0 and everything was fine with my OAuth client ID. And finally I solved it, so I created SHA1 as per documentation, but I run my app in debug mode (Build variant) and always had resultCode=0. Just switched to release mode and problem is gone, now resultCode=-1 as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With