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

Android 11 : pdf document throw com.android.providers.media.documents throw NullpointerException #7

Open
alexist opened this issue Jun 18, 2021 · 16 comments

Comments

@alexist
Copy link
Contributor

alexist commented Jun 18, 2021

When i select a pdf document, the content uri is

content://com.android.providers.media.documents/document/document%3A30

Logcat logs :

D/[FilePath plugin]:: File - Authority: com.android.providers.media.documents, Fragment: null, Port: -1, Query: null, Scheme: content, Host: com.android.providers.media.documents, Segments: [document, document:30]

FilePath.getPath is looking for a media document

       // MediaProvider
        else if (isMediaDocument(uri)) {

The docId is document:30, type is "document"

But doesn't handle "document"

           Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

=> contenUri is Null

@alexist
Copy link
Contributor Author

alexist commented Jun 18, 2021

It's look like version 1.1.6 fix this issue, but not yet available in npm.
Can you publish this version ?

Thanks,

@farfromrefug
Copy link
Member

@alexist it is now released!

@kislasi
Copy link

kislasi commented Jun 29, 2021

@farfromrefug @alexist
now there is no error but no file as well:
promise returns: {
"files": [
null
],
"android": {}
}
but for media files the promise works and returns: {
"files": [
"/storage/emulated/0/Download/sam-moqadam-cU5TUyEaZXQ-unsplash.jpg"
],
"android": {}
}

@farfromrefug
Copy link
Member

@kislasi emulator?

@kislasi
Copy link

kislasi commented Jun 29, 2021

@farfromrefug yes on android emulator

@farfromrefug
Copy link
Member

@kislasi ok test on real device. For me 60% of the time it returns null on emulator.

@kislasi
Copy link

kislasi commented Jun 29, 2021

@farfromrefug
it works on android 10on a real device - but not on android 11 at all

@farfromrefug
Copy link
Member

@kislasi ok seems like a bug then. Dont really have time to debug this those days. Could you create a simple repro example?

@kislasi
Copy link

kislasi commented Jun 29, 2021

openFilePicker({ extensions: ['pdf'], multipleSelection: true, pickerMode: 5 }).then(res => { console.log('SUCCESS', res.files.length > 0); }).catch(err => { console.log('ERROR', err); });

on android 10 the log is: SUCCESS true
but on android 11 device (or emulators) the log is:SUCCESS false

@farfromrefug is it what you need?

@farfromrefug
Copy link
Member

@kislasi thanks i ll try to reproduce but dont know when though :s

@alexist
Copy link
Contributor Author

alexist commented Jun 30, 2021

Version 1.1.6 fix my issue for both emulator and device android 11.

Can you attach logcat output ? The logcat log when i select a PDF document in Document folder is :

2021-06-30 08:59:27.778 23695-23695/yourpackage D/[FilePath plugin]:: File - Authority: com.android.providers.media.documents, Fragment: null, Port: -1, Query: null, Scheme: content, Host: com.android.providers.media.documents, Segments: [document, document:30]
2021-06-30 08:59:27.782 23695-23695yourpackageI/[FilePath plugin]:: document

@kislasi
Copy link

kislasi commented Aug 9, 2021

Hi @alexist
sorry for the late replay, please look at the logcat attached:
logcat.txt

@zamblas
Copy link

zamblas commented Sep 10, 2021

I'm also having the same problem, does anyone have a solution?

@Ederagp
Copy link

Ederagp commented Nov 11, 2021

the same problem here, any solution?

@farfromrefug
Copy link
Member

@Ederagp working on it. But the bug is not only here but in N too. We need to fix this in N

@jacopo69
Copy link

Hi @farfromrefug
do you have any news about the bug?

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

7 participants
@farfromrefug @alexist @zamblas @Ederagp @kislasi @jacopo69 and others