question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Caused by: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/3033

See original GitHub issue

Describe 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:closed
  • Created 5 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
joye-wangcommented, Dec 10, 2019

同样的问题

the version of utilcode: 1.26.0
device: 小米9 SE
device version: Android 9, API 28

选择下载里的文件,uri 为content://com.android.providers.downloads.documents/document/239 使用UriUtils.uri2File(uri)会崩溃 但使用https://github.com/coltoscosmin/FileUtils/blob/master/FileUtils.java可以正常运行

0reactions
Blankjcommented, Apr 25, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found