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

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

Open
dtumonasingh opened this issue Oct 7, 2022 · 19 comments

Comments

@dtumonasingh
Copy link
Contributor

dtumonasingh commented Oct 7, 2022

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

@frozencap
Copy link

@dtumonasingh what device are you testing on ?

@dtumonasingh
Copy link
Contributor Author

@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
Copy link
Contributor Author

dtumonasingh commented Oct 10, 2022

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..

@frozencap
Copy link

frozencap commented Oct 13, 2022

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

@Talhafayyaz11
Copy link

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

@Arkan4ik
Copy link

@Talhafayyaz11 have you solved?

@Talhafayyaz11
Copy link

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

@berk9595
Copy link

berk9595 commented Dec 25, 2022

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

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

@SMARTMICROWORLD
Copy link

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!😊

@ayoubshah2720
Copy link

ayoubshah2720 commented Jul 26, 2023

Added these permissions works for Android 13
image

@vishalSharmaCfcs
Copy link

<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

@RodolfoGS
Copy link
Contributor

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

@1Jesper1
Copy link

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

@RodolfoGS
Copy link
Contributor

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, #1974

@kmsayem12
Copy link

<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.

@Jatindarji03
Copy link

Same problem with me also

@AmaluThomas
Copy link

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

@Kavinduweb
Copy link

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

// you add this

@Kavinduweb
Copy link

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>

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

15 participants