Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Drive for Android SDK Doesn't List Files
    primarykey
    data
    text
    <p>I've got a really odd problem with the Google Drive Android SDK. I've been using it for several months now, and until last week it performed perfectly. However, there is now a really odd error, which doesn't occur all the time but does 9 out of 10 times.</p> <p>I'm trying to list the user's files and folders stored in a particular Google Drive folder. When I'm trying to use the method Drive.files().list().execute(), 9 out of 10 times literally nothing happens. The method just hangs, and even if I leave it for an hour, it just remains doing... nothing.</p> <p>The code I'm using is below - all of this being run within the doInBackground of an AsyncTask. I've checked credentials - they are all fine, as is the app's certificate's SHA1 hash. No exceptions are thrown. Google searches have yielded nothing. Here is the particular bit of code that's bothering me:</p> <pre><code> try { GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2( SettingsActivity.this, Arrays.asList(DriveScopes.DRIVE)); if (googleAccountName != null &amp;&amp; googleAccountName.length() &gt; 0) { credential.setSelectedAccountName(googleAccountName); Drive service = new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential).build(); service.files().list().execute(); // Google Drive fails here } else { // ... } } catch (final UserRecoverableAuthIOException e) { // Authorisation Needed runOnUiThread(new Runnable() { @Override public void run() { try { startActivityForResult(e.getIntent(), REQUEST_AUTHORISE_GDRIVE); } catch (Exception e) { Log.e("SettingsActivity: Google Drive", "Unable to add Google Drive account due to Exception after trying to show the Google Drive authroise request intent, as the UserRecoverableIOException was originally thrown. Error message:\n" + e.getMessage()); } } }); Log.d("SettingsActivity: Google Drive", "UserRecoverableAuthIOException when trying to add Google Drive account. This is normal if this is the first time the user has tried to use Google Drive. Error message:\n" + e.getMessage()); return; } catch (Exception e) { Log.e("SettingsActivity: Google Drive", "Unable to add Google Drive account. Error message:\n" + e.getMessage()); return; } </code></pre> <p>I'm using Drive API v2. Thanks everyone!</p> <h1>Edit</h1> <p>Having played around a bit more, it turns out this isn't for just listing files. Trying to interact with any file on Google Drive behaves the same way - deleting, downloading, creating... Anything! I have also noticed that putting the device in aeroplane mode so it has not internet access makes no difference either: Google Drive doesn't throw an exception, or even return, it just freezes the thread it's on.</p> <p>I've updated to the very latest Drive API lib but that hasn't helped. I remembered that the error happened soon after I added the JSch SSH library to the project, so I removed that, but it made no difference. Removing and re-adding the Drive API v2 has made no difference either, and nor has cleaning the project.</p> <h1>Edit 2</h1> <p>I've found something which may be significant. On the Google Developer console, I had some Drive errors recorded as follows:</p> <pre><code>TOP ERRORS: Requests % Requests Methods Error codes 18 38.30% drive.files.list 400 14 29.79% drive.files.insert 500 11 23.40% drive.files.update 500 4 8.51% drive.files.get 400 </code></pre> <p>Do you reckon these are the errors? How could I fix them? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload