Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open document with URI: com.android.providers.downloads.documents . #7

Closed
starction opened this issue Nov 22, 2018 · 34 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@starction
Copy link

starction commented Nov 22, 2018

Cannot open document with URI: com.android.providers.downloads.documents.
App crashes when attaching document of above URI with below error :

I/FilePicker( 7038): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker( 7038): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker( 7038): URI:content://com.android.providers.downloads.documents/document/2350
E/FilePathPicker( 7038): +++ API 19 URI :: content://com.android.providers.downloads.documents/document/2350
E/FilePathPicker( 7038): +++ Document URI
E/FilePathPicker( 7038): +++ Downloads External Document URI
D/AndroidRuntime( 7038): Shutting down VM
E/AndroidRuntime( 7038): FATAL EXCEPTION: main
E/AndroidRuntime( 7038): Process: com.coromandel.ideaspace, PID: 7038
E/AndroidRuntime( 7038): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=43, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/2350 flg=0x43 }} to activity {com.coromandel.ideaspace/com.coromandel.ideaspace.MainActivity}: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/2350
E/AndroidRuntime( 7038): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4440)
E/AndroidRuntime( 7038): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4484)
E/AndroidRuntime( 7038): 	at android.app.ActivityThread.-wrap19(Unknown Source:0)
E/AndroidRuntime( 7038): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1743)
E/AndroidRuntime( 7038): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 7038): 	at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime( 7038): 	at android.app.ActivityThread.main(ActivityThread.java:6753)
E/AndroidRuntime( 7038): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 7038): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
E/AndroidRuntime( 7038): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
E/AndroidRuntime( 7038): Caused by: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/2350
E/AndroidRuntime( 7038): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
E/AndroidRuntime( 7038): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
E/AndroidRuntime( 7038): 	at android.content.ContentProviderProxy.query(ContentProviderNative.java:432)
E/AndroidRuntime( 7038): 	at android.content.ContentResolver.query(ContentResolver.java:793)
E/AndroidRuntime( 7038): 	at android.content.ContentResolver.query(ContentResolver.java:712)
E/AndroidRuntime( 7038): 	at android.content.ContentResolver.query(ContentResolver.java:670)
E/AndroidRuntime( 7038): 	at com.mr.flutter.plugin.filepicker.FilePath.getDataColumn(FilePath.java:121)
E/AndroidRuntime( 7038): 	at com.mr.flutter.plugin.filepicker.FilePath.getForApi19(FilePath.java:66)
E/AndroidRuntime( 7038): 	at com.mr.flutter.plugin.filepicker.FilePath.getPath(FilePath.java:26)
E/AndroidRuntime( 7038): 	at com.mr.flutter.plugin.filepicker.FilePickerPlugin$1.onActivityResult(FilePickerPlugin.java:49)
E/AndroidRuntime( 7038): 	at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:210)
E/AndroidRuntime( 7038): 	at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139)
E/AndroidRuntime( 7038): 	at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:138)
E/AndroidRuntime( 7038): 	at android.app.Activity.dispatchActivityResult(Activity.java:7317)
E/AndroidRuntime( 7038): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4436)
E/AndroidRuntime( 7038): 	... 9 more
W/OPDiagnose( 7038): getService:OPDiagnoseService NULL
D/OSTracker( 7038): OS Event: crash
@starction starction changed the title Cannot open fileCannot handle document with URI: com.google.android.apps.docs.storage Always result same file path /data/user/0/com.example.omahdana/cache/Document Cannot open document with URI: com.android.providers.downloads.documents . Nov 22, 2018
@miguelpruivo
Copy link
Owner

miguelpruivo commented Nov 30, 2018

@sonathati thank you for your feedback, may I ask what is the source of the file?

Miguel

@NukanTran
Copy link

NukanTran commented Dec 3, 2018

same issue for pdf file in Download

@miguelpruivo
Copy link
Owner

@NukanTran what’s the path from the file you’re trying to load? Can you post your logs?

@NukanTran
Copy link

I/FilePicker( 6736): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker( 6736): URI:content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fa.pdf
E/FilePathPicker( 6736): +++ API 19 URI :: content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fa.pdf
E/FilePathPicker( 6736): +++ Document URI
E/FilePathPicker( 6736): +++ Downloads External Document URI
D/AndroidRuntime( 6736): Shutting down VM
E/AndroidRuntime( 6736): FATAL EXCEPTION: main
E/AndroidRuntime( 6736): Process: com.example.mytest, PID: 6736
E/AndroidRuntime( 6736): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=43, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/a.pdf flg=0x43 }} to activity {com.example.mytest/com.example.mytest.MainActivity}: java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/a.pdf"
E/AndroidRuntime( 6736): at android.app.ActivityThread.deliverResults(ActivityThread.java:4324)
E/AndroidRuntime( 6736): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4367)
E/AndroidRuntime( 6736): at android.app.ActivityThread.-wrap19(Unknown Source:0)
E/AndroidRuntime( 6736): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649)
E/AndroidRuntime( 6736): at android.os.Handler.dispatchMessage(Handler.java:105)
E/AndroidRuntime( 6736): at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime( 6736): at android.app.ActivityThread.main(ActivityThread.java:6541)
E/AndroidRuntime( 6736): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6736): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/AndroidRuntime( 6736): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
E/AndroidRuntime( 6736): Caused by: java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/a.pdf"
E/AndroidRuntime( 6736): at java.lang.Long.parseLong(Long.java:590)
E/AndroidRuntime( 6736): at java.lang.Long.valueOf(Long.java:804)
E/AndroidRuntime( 6736): at com.mr.flutter.plugin.filepicker.FilePath.getForApi19(FilePath.java:64)
E/AndroidRuntime( 6736): at com.mr.flutter.plugin.filepicker.FilePath.getPath(FilePath.java:26)
E/AndroidRuntime( 6736): at com.mr.flutter.plugin.filepicker.FilePickerPlugin$1.onActivityResult(FilePickerPlugin.java:49)
E/AndroidRuntime( 6736): at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:210)
E/AndroidRuntime( 6736): at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139)
E/AndroidRuntime( 6736): at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:138)
E/AndroidRuntime( 6736): at android.app.Activity.dispatchActivityResult(Activity.java:7235)
E/AndroidRuntime( 6736): at android.app.ActivityThread.deliverResults(ActivityThread.java:4320)
E/AndroidRuntime( 6736): ... 9 more

this is my logs

@miguelpruivo
Copy link
Owner

@NukanTran Thank you. What’s the android version?

@NukanTran
Copy link

Android 8.0 in Genymoution

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 3, 2018

Android 8.0 in Genymoution

@NukanTran I might take a look into it later on. However, you are free to use the version on the beta branch because it's ahead of the master and has some updates.

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 6, 2018

@NukanTran @sonathati @zean00 apparently there are some files started with "raw" string that may lead to this issue on Android 8.0. Doesn't seem to happen with other versions though.

I couldn't replicate the issue, however I'm PR a fix to the beta branch and maybe later today merge a version 1.0 on the master along with dart pub update.

Let me know if it worked for you.

edit: version 1.0 it's now live with the fixes on dart pub, thank you for your feedback.

@starction
Copy link
Author

@miguelpruivo I just tried 1.0.2 from pub and build fails

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':file_picker:debugCompileClasspath'.
> Failed to transform file 'flutter.jar' to match attributes {artifactType=android-classes} using transform JarTransform
   > Transform output file /Users/miguelruivo/DevTools/flutter/bin/cache/artifacts/engine/android-arm64/flutter.jar does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s
Finished with error: Gradle task assembleDebug failed with exit code 1

Flutter version:
Flutter (Channel beta, v0.11.9, on Mac OS X 10.13.6 17G3025, locale en-IN)

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 6, 2018

@sonathati glad that you’ve spotted it. I know what it is, that’s something that shouldn’t had been committed, probably due to a later git squash, my bad. I’ll fix it later today.

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 7, 2018

@sonathati everything should be working fine by now on 1.0.3, let me know if you find anything else.
Sorry for any inconvenience.

@starction
Copy link
Author

@miguelpruivo I am not able to get the file name when picked from open from view. But Iam able to retrieve the file name when attached from file manager available in the drawer

I/FilePicker( 9298): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker( 9298): URI:content://com.android.providers.downloads.documents/document/3023
E/FilePathPicker( 9298): +++ API 19 URI :: content://com.android.providers.downloads.documents/document/3023
E/FilePathPicker( 9298): +++ Document URI
E/FilePathPicker( 9298): +++ Downloads External Document URI
E/FilePathPicker( 9298): +++ Something went wrong while retrieving document path: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3023
I/FilePicker( 9298): Loaded file from cloud created on:/data/user/0/com.coromandel.ideaspace/cache/Document
I/FilePicker( 9298): Absolute file path:/data/user/0/com.coromandel.ideaspace/cache/Document
I/flutter ( 9298):  /data/user/0/com.coromandel.ideaspace/cache/Document
I/FilePicker( 9298): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker( 9298): URI:content://com.android.externalstorage.documents/document/primary%3ADownload%2F009E2D7C02DF488285C3409DC93A52D7.pdf
E/FilePathPicker( 9298): +++ API 19 URI :: content://com.android.externalstorage.documents/document/primary%3ADownload%2F009E2D7C02DF488285C3409DC93A52D7.pdf
E/FilePathPicker( 9298): +++ Document URI
E/FilePathPicker( 9298): +++ External Document URI
E/FilePathPicker( 9298): +++ Primary External Document URI
I/FilePicker( 9298): Absolute file path:/storage/emulated/0/Download/009E2D7C02DF488285C3409DC93A52D7.pdf
I/flutter ( 9298): /storage/emulated/0/Download/009E2D7C02DF488285C3409DC93A52D7.pdf

@miguelpruivo
Copy link
Owner

@sonathati I believe that is already fixed in the beta branch, could you give it a try? (You’ll need to add to your pubspec by using a git ref dependency).

@starction
Copy link
Author

starction commented Dec 27, 2018

@miguelpruivo I have tried in latest beta branch by adding git ref dependency in my pubspec. But still not able to get the file name. Following are the logs

I/FilePicker(31444): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker(31444): Requesting permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker(31444): Checking permission: android.permission.WRITE_EXTERNAL_STORAGE
I/FilePicker(31444): URI:content://com.android.providers.downloads.documents/document/3464
E/FilePathPicker(31444): +++ API 19 URI :: content://com.android.providers.downloads.documents/document/3464
E/FilePathPicker(31444): +++ Document URI
E/FilePathPicker(31444): +++ Downloads External Document URI
E/FilePathPicker(31444): +++ Something went wrong while retrieving document path: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3464
I/FilePicker(31444): Loaded file from cloud created on:/data/user/0/com.coromandel.ideaspace/cache/Document
I/FilePicker(31444): Absolute file path:/data/user/0/com.coromandel.ideaspace/cache/Document
I/flutter (31444): /data/user/0/com.coromandel.ideaspace/cache/Document

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 27, 2018

Hi again @sonathati , this seems to be a very specific/tricky issue that might be related to the path of downloads folder or a disabled download manager. Anyway, I've committed an update that tries to solve or, at least, try to understand the issue. Could you clean & build with the beta again, to give it a try?

Thank you.

@starction
Copy link
Author

starction commented Dec 28, 2018

@miguelpruivo I could see issue still exists with the latest update, beta branch.
Issue is not seen for the same file attached from different view. Attaching the logs for file StoreList.pdf for both uploading URIs

Working case:

I/FilePicker(32236): URI:content://com.android.externalstorage.documents/document/primary%3ADownload%2FStoreList.pdf
E/FilePathPicker(32236): +++ API 19 URI :: content://com.android.externalstorage.documents/document/primary%3ADownload%2FStoreList.pdf
E/FilePathPicker(32236): +++ Document URI
E/FilePathPicker(32236): +++ External Document URI
E/FilePathPicker(32236): +++ Primary External Document URI
I/FilePicker(32236): Absolute file path:/storage/emulated/0/Download/StoreList.pdf

Not working case:

I/FilePicker(32236): URI:content://com.android.providers.downloads.documents/document/3006
E/FilePathPicker(32236): +++ API 19 URI :: content://com.android.providers.downloads.documents/document/3006
E/FilePathPicker(32236): +++ Document URI
E/FilePathPicker(32236): +++ Downloads External Document URI
E/FilePathPicker(32236): +++ Something went wrong while retrieving document path: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3006
I/FilePicker(32236): Loaded file from cloud created on:/data/user/0/com.coromandel.ideaspace/cache/Document
I/FilePicker(32236): Absolute file path:/data/user/0/com.coromandel.ideaspace/cache/Document

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 28, 2018

Can I ask you where actually you’re trying to load the second path? I remember having an issue where some androids would display email attachments on the recent files but the files weren’t actually there, it was like a placeholder.

Also @sonathati, can you clean and try with file_picker: ^1.1.1 that is already on the dart pub?

@miguelpruivo miguelpruivo reopened this Dec 28, 2018
@miguelpruivo miguelpruivo added the triage Further information is requested label Dec 28, 2018
@pushangupta
Copy link

@miguelpruivo I have noticed that this bug started from image_picker provide by flutter team. You are right about the disabled downloads manager. But one thing I noticed in your version was that file picker works great when the file type is set to any. But as soon as file type is set IMAGE, it fails and gives the fatal exception. I think when we fail to retrieve the file path, we must copy the file to the cache directory and then get the path from there. It seems you are already implementing this for documents but since you are using image_picker as the source for picking files, it fails.

@miguelpruivo
Copy link
Owner

Thank you for the insights @pushangupta can you confirm if you are using FileType.CAMERA or FileType.IMAGE when this issue happens @sonathati?

@pushangupta
Copy link

@miguelpruivo FileType.IMAGE

@pushangupta
Copy link

@miguelpruivo Brother I did a little experiment. I changed the FileType to CUSTOM and gave file extension as JPG and guess what.. It fetched the exact same file it was failing on. Just a quick suggestion. If multiple file types(like JPG, PNG, SVG or JPEG) could be supported at the same time it would be better

@miguelpruivo
Copy link
Owner

miguelpruivo commented Dec 28, 2018

@pushangupta that’s why it has the FileType.IMAGE, so it can filter all image file types at once, otherwise it wouldn’t make sense.

@pushangupta
Copy link

@miguelpruivo I mean, FileType.IMAGE surely uses image_picker... right? I am trying to avoid image_picker. Moreover if, for example, I wanted to select docs of extensions pdf, docx or ppt only what can I do?

@miguelpruivo
Copy link
Owner

@pushangupta right now you’d have to use FileType.ALL for that matter, but it’s a good suggestion that in a future update I add a FileType.DOC or so that will gather all of those file types in a filter at once.

@tiholic
Copy link

tiholic commented Jan 16, 2019

Sure, I'll try and let you know

@tiholic
Copy link

tiholic commented Jan 16, 2019

It works great. I've tested for images, videos and pdf's.

#26

@miguelpruivo
Copy link
Owner

@tiholic does it fix this specific issue?

@tiholic
Copy link

tiholic commented Jan 16, 2019

Yes, now we can pick all types of files from downloads

@tiholic
Copy link

tiholic commented Jan 20, 2019

flutter/flutter#21863

Issue closed, you can update the version.

@miguelpruivo miguelpruivo added fixed on beta and removed triage Further information is requested labels Jan 29, 2019
@miguelpruivo miguelpruivo added this to the Goals milestone Feb 7, 2019
@Zfinix Zfinix mentioned this issue Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants