Adding second account breaks Google Drive
Software and hardware versions
Collect v1.4.16, Android 6.0, Moto X Pure
Problem description
When I add a second gmail account, the collect break with NPE.
Steps to reproduce the problem
- Ensure your google account is not connected to ODK yet: Google Account Permissions (If you have not visited this in a while, now is a good time to go through it).
- In general settings, change the platform to "Google Drive, Google Sheets"
- Select your primary gmail account for the google account.
- Go to get blank form section and press "My Drive"
- It will ask you to allow Collect to access your drive.
- Add a second gmail account to your phone: Add Account.
- Change your google account in the general settings to the new account.
- Go to the get blank form section and press "My Drive" and Collect will crash.
- Adding a third gmail account strangely make Collect work again.
Expected behavior
Collect should allow adding the second account without crashing.
Other information
This might not even be issue on the Collect side.
@nribeka Can you add a stack trace please?
The error logs similar to this, I'm getting this from the master branch:
03-24 13:38:42.171 15916-15982/org.odk.collect.android E/GoogleDriveActivity: null
com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:301)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at org.odk.collect.android.activities.GoogleDriveActivity$RetrieveDriveFileContentsAsyncTask.doInBackground(GoogleDriveActivity.java:790)
at org.odk.collect.android.activities.GoogleDriveActivity$RetrieveDriveFileContentsAsyncTask.doInBackground(GoogleDriveActivity.java:765)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.zze$1.zzat(Unknown Source)
at com.google.android.gms.auth.zze$1.zzau(Unknown Source)
at com.google.android.gms.auth.zze.zza(Unknown Source)
at com.google.android.gms.auth.zze.zzc(Unknown Source)
at com.google.android.gms.auth.zze.getToken(Unknown Source)
at com.google.android.gms.auth.zze.getToken(Unknown Source)
at com.google.android.gms.auth.zze.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:269)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:294)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at org.odk.collect.android.activities.GoogleDriveActivity$RetrieveDriveFileContentsAsyncTask.doInBackground(GoogleDriveActivity.java:790)
at org.odk.collect.android.activities.GoogleDriveActivity$RetrieveDriveFileContentsAsyncTask.doInBackground(GoogleDriveActivity.java:765)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
03-24 13:38:42.171 15916-15982/org.odk.collect.android E/drive: Error occurred : Unable to fetch drive contents
@lognaturel I think the best way to try to reproduce this issue is using accounts that never connect to Collect before.
@nribeka I tried running the app on Nexus 5 Android 6 by following the steps that you mentioned but could not be able to produce any error.
@lakshyagupta21 have you ever connect your Collect to your drive before and did you remove ODK from your authorized application? I can get this somewhat consistently (sometimes I can get to the Drive).
Yeah i connected once but i removed ODK from authorized applications and tested for my other 4 accounts as well which are not connected with ODK before.
Created a new account and wasn't able to reproduce this on physical Nexus 5, Android 6.0.1. @nribeka Did you only get it with a new account or also with an existing account that you've revoked authorization for? When you get the failure, what happens if you relaunch Collect and try again?
@lognaturel @nribeka I wasn't able to reproduce this issue as well.
Hi all!. I also wasn't able to reproduce the bug
@nribeka Are you still able to reproduce it?
Seems to be working this time @lognaturel. I think we can close it for now?
Cool! I think #767 may have also addressed it.
Oops, #776 rather.