document-picker icon indicating copy to clipboard operation
document-picker copied to clipboard

[Android 13, 14]: DocumentPicker throws an error [Error: User canceled document picker]

Open aviktius opened this issue 1 year ago • 9 comments

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 avatar Dec 15 '23 07:12 aviktius

any updates on that?

aviktius avatar Apr 24 '24 08:04 aviktius

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

vonovak avatar Apr 24 '24 09:04 vonovak

Same issue here.

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

TwistedMinda avatar Apr 24 '24 11:04 TwistedMinda

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

Thanks, works well for me either

aviktius avatar Apr 25 '24 08:04 aviktius

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

vonovak avatar May 02 '24 21:05 vonovak

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.

VBarzionov avatar Jul 26 '24 15:07 VBarzionov

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

anisimov74 avatar Sep 13 '24 14:09 anisimov74

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)

mgroeneweg avatar Sep 21 '24 04:09 mgroeneweg

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

yossularko avatar Oct 11 '24 07:10 yossularko