react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

In Apps targeting Android 13, openPicker is not working. It does not ask for permission and camera roll does not open.

Open dtumonasingh opened this issue 2 years ago • 19 comments

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.38.0
  • react-native v0.68

Platform

Tell us to which platform this issue is related

  • Android

Expected behaviour

Camera roll i:e openPicker function should ask for permission

Actual behaviour

Open Picker is not asking for permission

Steps to reproduce

  1. Call OpenPicker function after upgrading app target to SDK 33

Attachments

// stacktrace or any other useful debug info

Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate

dtumonasingh avatar Oct 07 '22 07:10 dtumonasingh

@dtumonasingh what device are you testing on ?

frozencap avatar Oct 08 '22 12:10 frozencap

@dtumonasingh what device are you testing on ?

I am testing on Pixel 4 simulator, the app targets Android 13 and the device also is on Android 13. When the app targets Android 12, no matter what the device, the openPicker ask for permission, only on Android 13 we see this problem. My guess is it has something to do with the WRITE_EXTERNAL_STORAGE permission it asks for,

dtumonasingh avatar Oct 10 '22 05:10 dtumonasingh

Adding ACCESS_MEDIA_IMAGES instead of WRITE_EXTERNAL_STORAGE at this line helped me get the permission dialog when opening gallery using the openPicker function. I am not sure what other permission is also needed to be added in place of WRITE_EXTERNAL_STORAGE to give WRITE permission in case of Apps targeting Android 13.

According to this Bug from Android 13 the WRITE_EXTERNAL_STORAGE permission does not contain the READ_EXTERNAL_STORAGE permission implicitly, that could be the reason for the openPicker to stop working..

dtumonasingh avatar Oct 10 '22 11:10 dtumonasingh

@dtumonasingh can confirm this works. May want to close the issue and PR the docs. Thanks a ton 🥳

frozencap avatar Oct 13 '22 17:10 frozencap

What is the update here. Can guys please merge the above PR. So i can use this in apps targeting android 13.

Talhafayyaz11 avatar Dec 13 '22 11:12 Talhafayyaz11

@Talhafayyaz11 have you solved?

Arkan4ik avatar Dec 14 '22 08:12 Arkan4ik

i tried to run on real device with appropriate permission and it works find

Talhafayyaz11 avatar Dec 14 '22 08:12 Talhafayyaz11

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

Adding this line into android/app/src/main/AndroidManifest.xml fixed mine.

berk9595 avatar Dec 25 '22 16:12 berk9595

Uninstall using npm uninstall react-native-image-crop-picker and again install using npm i react-native-image-crop-picker and don't forget to add <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/> to android/app/src/main/AndroidManifest.xml. Have a gread day!😊

SMARTMICROWORLD avatar Feb 02 '23 16:02 SMARTMICROWORLD

Added these permissions works for Android 13 image

ayoubshah2720 avatar Jul 26 '23 07:07 ayoubshah2720

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

Adding this line into android/app/src/main/AndroidManifest.xml fixed mine.

Working for me too

vishalSharmaCfcs avatar Aug 09 '23 07:08 vishalSharmaCfcs

I recommend you to apply the patch that I mentioned in this PR https://github.com/ivpusic/react-native-image-crop-picker/pull/1973#issuecomment-1719531114 instead of add the READ_MEDIA_IMAGES permission since that permission is not required to open the picker.

Note: If your app only needs to access images, photos, and videos, consider using the photo picker instead of declaring the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions.

Source: https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

RodolfoGS avatar Sep 14 '23 14:09 RodolfoGS

I recommend you to apply the patch that I mentioned in this PR #1973 (comment) instead of add the READ_MEDIA_IMAGES permission since that permission is not required to open the picker.

Note: If your app only needs to access images, photos, and videos, consider using the photo picker instead of declaring the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions.

Source: https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

What version do you use? Should be fixed in v0.39. https://github.com/ivpusic/react-native-image-crop-picker/releases/tag/v0.39.0

1Jesper1 avatar Sep 15 '23 12:09 1Jesper1

Should be fixed in v0.39

Yes, But...

I'm using version 0.40.0, and when I implemented it, I forgot to add android.permission.READ_MEDIA_IMAGES to my AndroidManifest.xml (because this requirement isn't mentioned in the Readme).

Before realizing that I had missed that, I began searching for a solution and implemented another library (react-native-image-picker). I noticed that they could open the picker without requiring any permission on Android 13. So, I started to read their code and I noticed that they were not using the READ_MEDIA_IMAGES permission. Afterward, I checked the Google Documentation and found this sentence:

Note: If your app only needs to access images, photos, and videos, consider using the photo picker instead of declaring the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions.

Source: https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

That is because the picker is part of the OS and there the user can select the picture that he want, so that is the final permission (the user's selection).

So, the solution is to simply remove that permission from the code, and you won't need to ask the user for any permission.

The same can be done with opening the camera; the CAMERA permission is not required. I have created another PR for that, https://github.com/ivpusic/react-native-image-crop-picker/pull/1974

RodolfoGS avatar Sep 15 '23 14:09 RodolfoGS

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/> Adding this line into android/app/src/main/AndroidManifest.xml fixed mine.

Thanks, Working for me.

kmsayem12 avatar Sep 18 '23 20:09 kmsayem12

Same problem with me also

Jatindarji03 avatar Jan 10 '24 03:01 Jatindarji03

Even after adding READ_MEDIA_IMAGES to manifest, still not able to select images and files in webview

AmaluThomas avatar May 06 '24 08:05 AmaluThomas

Perhaps it seems to be a problem that arises because Android does not allow http.

Please build a new Android after changing Android settings as follows.

android/app/src/main/AndroidManifest.xml

<application android:usesCleartextTraffic="true"> // you add this

Kavinduweb avatar Jul 11 '24 11:07 Kavinduweb

Perhaps it seems to be a problem that arises because Android does not allow http.

Please build a new Android after changing Android settings as follows.

android/app/src/main/AndroidManifest.xml

<application android:usesCleartextTraffic="true"> // you add this ... </application>

Kavinduweb avatar Jul 11 '24 11:07 Kavinduweb