Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

java.util.concurrent.ExecutionException: com.google.android.gms.common.api.ApiException: 17: API: Drive.API_CONNECTIONLESS is not available on this device. at #75

Open
TonyTangAndroid opened this issue Mar 30, 2018 · 22 comments
Assignees

Comments

@TonyTangAndroid
Copy link

Here is the story. I had integrated Google Drive Android SDK (8.1.0) into my app (AnyCopy) around three years ago. And I followed the tutorial to set up properly including adding credentials and api key. Everything worked okay. I could backup and restore my data without any problem. Even today it works okay if I download it from Google Play.

Recently I have been trying to refactor AnyCopy and integrate the newest Google Drive Android SDK (Google Play Service Version number 12.0.1 )into my app and experiencing a strange error with message

java.util.concurrent.ExecutionException: com.google.android.gms.common.api.ApiException: 17: API: Drive.API_CONNECTIONLESS is not available on this device. at com.google.android.gms.tasks.Tasks.zzc(Unknown Source) at com.google.android.gms.tasks.Tasks.await(Unknown Source)

However, if I create a new credential on Google Console with a different signing key. And the problem is resolved. I realize that the problem rooted from the credential configuration. However, I could not figure out how to resolve it as it might be a Google Drive SDK backwards compatibility bug. Anyone else has ever run into this issue? Any suggestion will he highly appreciated.

I also created a stackoverflow question here for anyone who is interested in answering there.

@denisraison
Copy link

Hey @TonyTangAndroid

Did you find out how to fix it?
I'm having the same issue and can't work it out.

Thanks

@TonyTangAndroid
Copy link
Author

Nope, unfortunately. I eventually was forced to upgrade to the latest Google Play Service 12.0.1 and used the deprecated API to support the functionality. I have been watching the repository. @asrivas has been actually following up with issues here. Hopefully, this issue will soon be addressed or advised.

@denisraison
Copy link

Hey @TonyTangAndroid , yep that's weird and I can't find much about that online. I'll probably need to do the same here to work that around :/
By the way, did you guys create an issue for google or something that I could follow too?
Thanks

@TonyTangAndroid
Copy link
Author

No. I could not find any place to raise such issue. Hence I posted it here and stackoverflow and keeps my fingers crossed ever since.

@denisraison
Copy link

Yep, I saw your issue there. No worries, we'll find that out soon.

@asrivas
Copy link
Contributor

asrivas commented May 29, 2018

Are you getting that error on a device or emulator and does it have the updated Google Play Services? Please do not use the deprecated API, please see the deprecation note and updated instructions:
https://developers.google.com/android/guides/google-api-client

You may follow the code in BaseDemoActivity for creating the Drive client:
https://github.com/gsuitedevs/android-samples/blob/master/drive/demos/app/src/main/java/com/google/android/gms/drive/sample/demo/BaseDemoActivity.java#L144

Full authentication instructions available here:
https://developers.google.com/drive/android/get-started

Can you provide the code that throws this exception?

@asrivas asrivas self-assigned this May 29, 2018
@TonyTangAndroid
Copy link
Author

@asrivas Thank you very very much for getting back to this issue. I am so excited to receive the email notification about your message.

I am using the Pixel 2 running Android 8.1.0. I could confirm that I have setup everything correctly.
I would believe that this is more than a backwards compatibility issue.

I would be more than happy to provide the sample code to reproduce this issue in next 12 hours.

@TonyTangAndroid
Copy link
Author

Hi @asrivas, I am afraid that it is really inconvenient for me to provide the whole code base with release key and API Key. However, this issue could only be reproduced with my legacy Google Drive API key. If I use a newer version, everything is okay. But I need to keep the backwards compatibility. So I had to use the deprecated API. By any chance, you could investigate this issue based on the error code?

Why such message will be shown?
Drive.API_CONNECTIONLESS is not available on this device.

@asrivas
Copy link
Contributor

asrivas commented May 31, 2018

I was looking for the API call that threw that exception. Please note though that we do not provide support for deprecated APIs.

@DreierF
Copy link

DreierF commented Jun 2, 2018

Hi @asrivas,
I'm experiencing exactly the same issue in my app.
To make sure there is no misunderstanding: The issue is not about using the legacy Google Drive API, but to use an OAuth 2.0-Client-ID which has already successfully been used with the legacy Google Drive API, but does no longer work with the new one (Correct @TonyTangAndroid ?)
What I tried:
I used the demos project from this repo, updated Gradle and the play service dependencies (see). Then added a new keystore and changed the app's application id (see)
When I add the SHA1 signature to a new project in the Goople Cloud Platform Console, enabled the Drive API and added an OAuth 2.0-Client-ID for the SHA1 and application id. => File creation etc. works as expected.
When I replace the keystore with the one of my production app and add the according OAuth 2.0-Client-ID everything still works, but as soon as I change the application id to the same as my production app (which already uses the old version of the Goodle Drive API and has an according OAuth Client ID) I get the Drive.API_CONNECTIONLESS is not available on this device error.

Any help would be very much appreciated 🙂
If there is any additional info I should provide please let me know

@Mjweathe
Copy link

Mjweathe commented Jun 6, 2018

I was also having this problem, and I just managed to fix it.

The cause for me:
At one point I asked for full scope access to drive from my android app, but this is not allowed. Quote from https://developers.google.com/drive/android/auth

Note: The Google Drive Android API currently only supports drive.file and drive.appfolder authorization scopes.

Solution:
To check if this is the problem for you, go to https://accounts.google.com/IssuedAuthSubTokens and click on your app in the list. In the "Has access to" section under Google Drive, look for "View and manage the files in your Google Drive." If you see this, it means that your android app has asked for the full scope, which will cause this error. Click "Remove Access" to remove all accesses, and also check to make sure you are no longer asking for the wrong permissions in your app. This allowed me to use the current api's without the "CONNECTIONLESS' error.

If you don't find that incorrect permission for your app, make sure to check ALL of your android apps. If you ask for full scope in one Android app, it will cause this error for all your apps, on any device where you are logged into the same account.

Hope this helps!

@denisraison
Copy link

Yeah @Mjweathe, I found that too.

I've replied to @TonyTangAndroid on his question here explaining that:
https://stackoverflow.com/questions/49568796/com-google-android-gms-common-api-apiexception-17-api-drive-api-connectionles/50661619#50661619

At least my problem was with the scope too.

@hksfho
Copy link

hksfho commented Jun 14, 2018

same problem
also have this error on demo

@hksfho
Copy link

hksfho commented Jun 19, 2018

create firebase project and import firebase service resolve my issue

@Panzki
Copy link

Panzki commented Jul 3, 2018

Hey everyone,
I have got the same error. I'm unable to retrieve or create files in a a signed in users Google Drive. Permissions seem to be correct, I requested them as followd: .requestScopes(Drive.SCOPE_FILE). I checked the granted permissions from the link @Mjweathe posted and they are set as

Google Drive
View and manage Google Drive files and folders that you have opened or created with this app

Google Drive API is enabled for the project as well. I have ran out of ideas at this point. Does anyone know a solution for this problem or possible errors I could have made?

Thanks

@kbboss
Copy link

kbboss commented Jul 6, 2018

@Panzki you need GoogleSignClient(getContext()).revokeAccess();

@Panzki
Copy link

Panzki commented Jul 9, 2018

@kbboss Thanks for the suggestion, unfortunately this did not resolve the issue.

@arpitjindal97
Copy link

I am also having this same issue. I tried the same app with no change on 2 other devices and it worked well but not working on mine. By the way, I have installed custom rom in my device with SELinux permissive.

@arpitjindal97
Copy link

arpitjindal97 commented Jul 10, 2018

I found the solution to my problem. When we build GoogleSignInOptions and add requestScopes i.e.

  • Drive.SCOPE_FILE
  • Drive.SCOPE_APPFOLDER

These scopes do not appear in consent screen. In fact, Consent screen doesn't appear so, your app doesn't get drive permissions at all.

GoogleSignInOptions signInOptions =
     new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
          .requestScopes(Scope("https://www.googleapis.com/auth/drive"))
          .requestScopes(Drive.SCOPE_FILE)
          .requestScopes(Drive.SCOPE_APPFOLDER)
          .requestEmail()
          .build();
GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, signInOptions);
startActivityForResult(googleSignInClient.getSignInIntent(), REQUEST_CODE_SIGN_IN);

You will see 3 drive permission in consent screen and then you can create folders which is visible to user also. Make sure you revoke the permission of your app from here

@wbaumann
Copy link

I'm also encountering the same 17: API: Drive.API_CONNECTIONLESS is not available on this device. when upgrading from the deprecated Drive.DriveApi apis to the new DriveClient ones. Judging from everyone else's experience, this seems to be due to having created an OAuth2 key in the GCP console for the old APIs.

Is there a suggested path forward for how to upgrade without breaking my existing OAuth keys? There's not a simple upgrade path for me otherwise, since I cannot deploy this to production without breaking the experience for everyone that is currently using the deprecated APIs.

@TonyTangAndroid
Copy link
Author

After all the feedback in this thread, it seems that any unexpected exception will trigger API_CONNECTIONLESS exception with little and misleading information. And engineer from Google Drive team possibly feel powerless on fixing this issue as they also could not gather any valid hint to help them. This is a good example to demonstrate that how bad it could be if the SDK Error handling logic is not designed properly.

@jfs52
Copy link

jfs52 commented Apr 8, 2019

I had the same problem. My app worked fine on 4 different devices when connected to the network. When offline (airplane mode), 3 of my devices failed the drive requestSync() with error 7 - device is offline. This error is handled by the app because cached metadata from a subsequent query() was available even though the device was offline.

The 4th device failed with error code 17 on both the requestSync() AND query() which was unexpected and caused application failure. If airplane mode was turned off, no errors were returned but they would occur again if airplane mode was turned on.

Signing out of the drive account and signing in again solved the problem. I have not been able to recreate the problem and have no idea of the root cause.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests