I'm in the process of producing a minimal workable example, to demonstrate the bug described in How to avoid from always loading cached app data from Google Drive
I had completed the code at https://github.com/yccheok/google-drive-bug
The code is intent to either update existing text file, or write a new text file.
However, when testing, I always get exception in driveContents.commit
Status status;
try {
status = driveContents.commit(googleApiClient, null).await();
} catch (java.lang.IllegalStateException e) {
// java.lang.IllegalStateException: DriveContents already closed.
Log.e(TAG, "", e);
return false;
}
The details of the exception is as follow.
java.lang.IllegalStateException: DriveContents already closed.
at com.google.android.gms.drive.internal.zzv.zza(Unknown Source)
at com.google.android.gms.drive.internal.zzv.commit(Unknown Source)
at org.yccheok.demo.Utils.saveToGoogleDrive(Utils.java:233)
at org.yccheok.demo.SaveFile123Task.doInBackground(SaveFile123Task.java:13)
at org.yccheok.demo.SaveFile123Task.doInBackground(SaveFile123Task.java:10)
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)
I had debugged for a long period, and still have no idea why. I don't think I had missed out any steps.
Correct API key is setup
Steps to reproduce the problem
- Click on
SAVE 123.TXT" WITH CONTENT "123"
button.
Not sure what steps I had missed out, which causes the exception always thrown at this line - https://github.com/yccheok/google-drive-bug/blob/master/app/src/main/java/org/yccheok/demo/Utils.java#L233
Thank you.