Caused by: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3033
See original GitHub issueDescribe the bug
A clear and concise description of what the bug is.
- The version of utilcode: 1.23.7
- The device: 小米6
- The version of device: API 26
The code of bug
UriUtils.uri2File
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 111 && data != null) {
if (resultCode == Activity.RESULT_OK) {
Uri uri = data.getData();
File file = UriUtils.uri2File(FilePickerActivity.this, uri);
String absolutePath = file.getAbsolutePath();
}
}
}
The stack of crash
2019-03-08 14:15:38.213 8143-8143/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wiki.cc, PID: 8143
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=111, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/3033 flg=0x1 }} to activity {com.wiki.cc/com.wiki.cc.ui.a.FilePickerActivity}: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3033
at android.app.ActivityThread.deliverResults(ActivityThread.java:4391)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4434)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1678)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6701)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
Caused by: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3033
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
at android.content.ContentResolver.query(ContentResolver.java:756)
at android.content.ContentResolver.query(ContentResolver.java:705)
at android.content.ContentResolver.query(ContentResolver.java:663)
at com.wiki.cc.util.UriUtils.getFileFromUri(UriUtils.java:120)
at com.wiki.cc.util.UriUtils.getFileFromUri(UriUtils.java:113)
at com.wiki.cc.util.UriUtils.uri2File(UriUtils.java:79)
at com.wiki.cc.ui.a.FilePickerActivity.onActivityResult(FilePickerActivity.java:53)
at android.app.Activity.dispatchActivityResult(Activity.java:7310)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4387)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4434)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1678)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6701)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (11 by maintainers)
Top Results From Across the Web
Unknown URI when trying to open downloaded image - Stack ...
For example, when opening with Google Photos I see this error in Logcat. E/DatabaseUtils: Writing exception to parcel java.lang.
Read more >ContentProvider not found [37124513] - Issue Tracker - Google
We see that some of our users are experiencing crashes with the following exception. java.lang.IllegalArgumentException: Unknown URL content://<uri>
Read more >New Agent startup fails with java.lang.IllegalArgumentException
Oracle Integration-OIC - Version 18.2.5 and later: New Agent startup fails with java.lang.IllegalArgumentException: URI is not absolute.
Read more >Data Studio 4.1.0.1 "java.lang.IllegalArgumentException - IBM
IllegalArgumentException : URI is not hierarchical" ... OnlineExtractDDLWizard$1.run(Unknown Source) ... Any idea what is causing this and how to fix it.
Read more >UnknownURISchemeException (JBoss Application Server
Unknown URI scheme. ... Constructs a UnknownURISchemeException with the specified cause. Method Summary. Methods inherited from class java.lang.Throwable.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
同样的问题
选择
下载
里的文件,uri 为content://com.android.providers.downloads.documents/document/239
使用UriUtils.uri2File(uri)
会崩溃 但使用https://github.com/coltoscosmin/FileUtils/blob/master/FileUtils.java
可以正常运行@newlai913 @tianyuxf 试试 1.28.2 版本,https://github.com/Blankj/AndroidUtilCode/issues/1223