react-native-image-crop-picker
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.
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
-
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 what device are you testing on ?
@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,
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 can confirm this works. May want to close the issue and PR the docs. Thanks a ton 🥳
What is the update here. Can guys please merge the above PR. So i can use this in apps targeting android 13.
@Talhafayyaz11 have you solved?
i tried to run on real device with appropriate permission and it works find
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
Adding this line into android/app/src/main/AndroidManifest.xml fixed mine.
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!😊
Added these permissions works for Android 13
<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
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
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
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
<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.
Same problem with me also
Even after adding READ_MEDIA_IMAGES to manifest, still not able to select images and files in webview
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
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>