Crash on Google Drive File Selection
i140394 opened this issue · comments
What version are you using?
Library: 0.1.9
OS: Android 6.0
Can you send me a link to a file I can test with? The size should not be zero.
Sure.
It's only happening when I am selecting drive file from Recents screen.
Can you please share the uri when selecting it from Google Drive and when you select it from Recents?
Ok. It is crashing for Google sheet/doc etc files from Recents and Drive also.
I will share you the Uris shortly.
For your reference: I think this is the same issue as below one
DownloadAsyncTask divide by zero #9
From Drive: content://com.google.android.apps.docs.storage/document/acc%3D9%3Bdoc%3Dencoded%3DJnO56ZsvMKX3juRDYo4DF7Xyod10TSNi6bERrFPTBkeJeXMci%2FlQaQ%3D%3D
From Recents:
content://com.google.android.apps.docs.storage/document/acc%3D9%3Bdoc%3Dencoded%3DJnO56ZsvMKX3juRDYo4DF7Xyod10TSNi6bERrFPTBkeJeXMci%2FlQaQ%3D%3D
I tested on my device with the demo application and I do not see the crash, please download the project and change the following:
to
intent.setType("application/pdf");
The run that on your device and see if you still get the error.
Yes. It is still crashing.
The other thing I do not understand is that your log is pointing to:
but the dividing is happening on line 93:
Please add this:
Log.e("Size =". ""+size);
here:
and let me know if the size is 0.
Hope this will help.
https://drive.google.com/open?id=171_Kg1UQYlwFKiLYBLz8uGmK9oRh2KG0
Please add this:
Log.e("Size =". ""+size);here:
and let me know if the size is 0.
Please check the above
OK. Sure
Thank you.
Please change the entire while
loop:
to the following:
while ((count = bis.read(data)) != -1) {
if (!isCancelled()) {
total += count;
if (size != -1) {
try {
publishProgress((int) ((total * 100) / size));
}catch(Exception e){
Log.i("PickiT -", "File size is less than 1");
publishProgress(0);
}
}
fos.write(data, 0, count);
}
}
Let me know if the crash goes away and I will update the library.
The crash is gone. But I was getting file size as 0. Is it because size is int field?
And my file size is less than 1MB. Is that it?
I have some test data in my google sheet.
Yes, the problem is that your file size is 0.23MB
for example, and it gets rounded to 0, thus the error. I'm busy updating the library.
OK. Thank You.
This is fixed in 0.1.10
. You can test it with the demo application if you would like.
Please test it and close the issue if it is fixed.