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 13, 14]: DocumentPicker throws an error [Error: User canceled document picker] #694

Open
aviktius opened this issue Dec 15, 2023 · 9 comments

Comments

@aviktius
Copy link

Bug report

Summary

DocumentPicker throws an error [Error: User canceled document picker] on Android 13 and 14. I found the same issue that has been fixed here which works perfectly with the latest version of the library (including Android 12) but fails on Android 13 and 14 with the same error.

Reproducible sample code

The issue is reproducible on Android devices with 13 and 14 versions of OS.

Steps to reproduce

  1. Update your Android device to the latest OS version (14)
  2. Update the document picker starting from version 8.1.4 (8.1.3 is the last working version in this case)
  3. Pick a file
  4. Get an error

Describe what you expected to happen:

  1. Document picker loads file(s)

Environment info

  • "react-native": "0.72.6"
  • "react-native-document-picker": "9.1.0",

Android version: 14.0

@aviktius
Copy link
Author

any updates on that?

@vonovak
Copy link
Collaborator

vonovak commented Apr 24, 2024

Hello and thanks for asking,
I now focus on improving the package for sponsors. I wrote an automated test suite for that package using Appium, and you can see an example recording here.

The tests were executed on real devices including Android 13 and 14 and didn't encounter the issue you're reporting.

Not a direct answer, but it is an update 🙂
Thank you

@TwistedMinda
Copy link

Same issue here.

Drop-in replacement expo-document-picker did the trick for me, just works.

@aviktius
Copy link
Author

Drop-in replacement expo-document-picker did the trick for me, just works.

Thanks, works well for me either

@vonovak
Copy link
Collaborator

vonovak commented May 2, 2024

Hi,
Just so I understand the original report: @aviktius are you saying that with Intent.createChooser, it worked for you on Android 14 (but not 12), and without Intent.createChooser it works on Android 12 but not 14?

The difference with expo's picker is that it uses Action.open_document, but this package uses Action.get_content.

You can use Action.open_document with the package for sponsors, see open mode.

Also see the differences in the ui for both intent types:

https://react-native-documents.github.io/docs/sponsor-only/picker/integrating-on-android

@VBarzionov
Copy link

VBarzionov commented Jul 26, 2024

Got same issuie only on Android14 (on Nothing Phone).
Android 10, 13 works fine.

Issue fixed after I reverted commit dsecribed here

my code in RNDocumentPickerModule.java:157 looks like

// currentActivity.startActivityForResult(intent, READ_REQUEST_CODE, Bundle.EMPTY);  // reverted this =>
currentActivity.startActivityForResult(Intent.createChooser(intent, null), READ_REQUEST_CODE, Bundle.EMPTY); // => to this

I've cheked this reverted code on Android 14, 13, 10 (Huawei P30).

P.S.
In Issue is mentioned Huawei P30 Pro. However on my P30 - original code works well. Have not tested other devices mentioned there.

@anisimov74
Copy link

On my Google Pixel with Android 14, it also stopped working. I can confirm that reverting the code fixes this issue for me.

@mgroeneweg
Copy link

mgroeneweg commented Sep 21, 2024

react-native-document-picker+9.3.1.patch
Reverting the commit mentioned above worked for me too. I created a patch to make it easier for others to use it. (Replaced the first patch file as it had picked up lots of binary stuff as well)

@yossularko
Copy link

same issue, please let me know when there is an update

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