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

Getting IllegalArgumentException #158

Open
vishrut2207 opened this issue Oct 22, 2018 · 9 comments
Open

Getting IllegalArgumentException #158

vishrut2207 opened this issue Oct 22, 2018 · 9 comments

Comments

@vishrut2207
Copy link

Fatal Exception: java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/2483
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:760)
at android.content.ContentResolver.query(ContentResolver.java:710)
at android.content.ContentResolver.query(ContentResolver.java:668)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.getDataAndMimeType(FileProcessorThread.java:445)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.getPathAndMimeType(FileProcessorThread.java:50039)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFile(FileProcessorThread.java:2190)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:42)

@smelfungus
Copy link

Same here:

    java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/8408
        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:802)
        at android.content.ContentResolver.query(ContentResolver.java:752)
        at android.content.ContentResolver.query(ContentResolver.java:710)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.getDataAndMimeType(FileProcessorThread.java:419)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.getPathAndMimeType(FileProcessorThread.java:370)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.getAbsolutePathIfAvailable(FileProcessorThread.java:344)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFile(FileProcessorThread.java:170)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFiles(FileProcessorThread.java:105)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.run(FileProcessorThread.java:79)

Looks like related to downloads file picking,
Pixel XL, Android 9
@coomar2841, address this please.

@ericksli
Copy link

I got the same issue as well

I am using emulator (Android 9)

2018-11-15 11:03:13.378 8072-8384/com.example.foo E/AndroidRuntime: FATAL EXCEPTION: Thread-17
    Process: com.example.foo, PID: 8072
    java.lang.IllegalArgumentException: Unknown URI: content://downloads/public_downloads/18
        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:802)
        at android.content.ContentResolver.query(ContentResolver.java:752)
        at android.content.ContentResolver.query(ContentResolver.java:710)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.getDataAndMimeType(FileProcessorThread.java:419)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.getPathAndMimeType(FileProcessorThread.java:370)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.getAbsolutePathIfAvailable(FileProcessorThread.java:344)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFile(FileProcessorThread.java:170)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFiles(FileProcessorThread.java:105)
        at com.kbeanie.multipicker.core.threads.FileProcessorThread.run(FileProcessorThread.java:79)
        at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:42)

@vijay3
Copy link

vijay3 commented Nov 16, 2018

The issue is fixed on 14 November, 2018. (Version 1.6)
Commit ID: 72fea9c

But folks are unable to add 1.6 version as gradle is unable to resolve it.
The issue is already reported. Hope it gets resolved soon.

@coomar2841
Copy link
Owner

Can you check with 1.6?

@vishrut2207
Copy link
Author

vishrut2207 commented Nov 19, 2018

After update App is not crashing but I am not able to pick that image. it is throwing PickerException.

com.kbeanie.multipicker.api.exceptions.PickerException: Unknown URI: content://downloads/public_downloads/747
at com.kbeanie.multipicker.core.threads.FileProcessorThread.getFromContentProvider(FileProcessorThread.java:300)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFile(FileProcessorThread.java:196)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFiles(FileProcessorThread.java:108)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.run(FileProcessorThread.java:80)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:42)
java.io.FileNotFoundException: content:/downloads/public_downloads/747 (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:200)
at java.io.FileInputStream.(FileInputStream.java:150)
at java.io.FileInputStream.(FileInputStream.java:103)
at android.media.ExifInterface.(ExifInterface.java:1334)
at com.kbeanie.multipicker.core.threads.FileProcessorThread.getWidthOfImage(FileProcessorThread.java:802)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.generateMetadata(ImageProcessorThread.java:96)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.postProcessImage(ImageProcessorThread.java:82)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.postProcessImages(ImageProcessorThread.java:66)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:43)
java.lang.NumberFormatException: For input string: ""
at java.lang.Integer.parseInt(Integer.java:620)
at java.lang.Integer.parseInt(Integer.java:643)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.generateMetadata(ImageProcessorThread.java:96)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.postProcessImage(ImageProcessorThread.java:82)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.postProcessImages(ImageProcessorThread.java:66)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:43)
com.kbeanie.multipicker.api.exceptions.PickerException: Error while generating thumbnail: 1 content://downloads/public_downloads/747
at com.kbeanie.multipicker.core.threads.FileProcessorThread.downScaleAndSaveImage(FileProcessorThread.java:789)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.generateThumbnails(ImageProcessorThread.java:103)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.postProcessImage(ImageProcessorThread.java:89)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.postProcessImages(ImageProcessorThread.java:66)
at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:43)

@coomar2841
Copy link
Owner

coomar2841 commented Nov 19, 2018 via email

@vishrut2207
Copy link
Author

@coomar2841 I have updated my comment.

@vishrut2207
Copy link
Author

@coomar2841 I have updated below code and its work perfectly in Android 8.1.0, 7.1.1, 6.0

if (isDownloadsDocument(uri)) {
                final String id = DocumentsContract.getDocumentId(uri);
                if (id.startsWith("raw:")) {
                    String[] data = new String[2];
                    data[0] = id.replaceFirst("raw:", "");
                    data[1] = null;
                    return data;
                }
                Uri contentUri = uri;

                String[] contentUriPrefixesToTry = new String[]{
                        "content://downloads/public_downloads",
                        "content://downloads/my_downloads"
                };

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {

                    for (String contentUriPrefix : contentUriPrefixesToTry) {
                        contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
                        try {
                            String[] data = getDataAndMimeType(contentUri, null, null, file.getType());
                            if (data != null) {
                                return data;
                            }
                        } catch (Exception ignored) {
                        }
                    }

                } else {
                    return getDataAndMimeType(contentUri, null, null, file.getType());
                }
            }

@anggit97
Copy link

@coomar2841 I have updated below code and its work perfectly in Android 8.1.0, 7.1.1, 6.0

if (isDownloadsDocument(uri)) {
                final String id = DocumentsContract.getDocumentId(uri);
                if (id.startsWith("raw:")) {
                    String[] data = new String[2];
                    data[0] = id.replaceFirst("raw:", "");
                    data[1] = null;
                    return data;
                }
                Uri contentUri = uri;

                String[] contentUriPrefixesToTry = new String[]{
                        "content://downloads/public_downloads",
                        "content://downloads/my_downloads"
                };

                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {

                    for (String contentUriPrefix : contentUriPrefixesToTry) {
                        contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
                        try {
                            String[] data = getDataAndMimeType(contentUri, null, null, file.getType());
                            if (data != null) {
                                return data;
                            }
                        } catch (Exception ignored) {
                        }
                    }

                } else {
                    return getDataAndMimeType(contentUri, null, null, file.getType());
                }
            }

what is getDataAndMimeType function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants