react-native-image-picker: Permission error
Bug
In android, image picker asks permission even though it was granted before. And after granted, image picker does not show anything with console error " Permissions weren’t granted". Tried in android 10 emulator.
Environment info
React native info output:
// paste it here
Library version: x.x.x
Steps To Reproduce
- Ask permission before running image picker
- Run image picker.
- It asks permission again, and even allowed, it errors out that “no permission granted” …
Describe what you expected to happen:
- Do not ask permission, if it is already granted
Reproducible sample code
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 27 (4 by maintainers)
This should be open. As we know Android 11 is getting a new permission with a different way to access the files. Is there any update for this? https://support.google.com/googleplay/android-developer/answer/10467955
FIXED ISSUE ON ANDROID 10 DEVICE exact response:
error: "/storage/emulated/0/DCIM/Camera/IMG_849.jpg: open failed: EACCES (Permission denied)"I’ve permission keys in Manifest file
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />FIX Add this permission in your manifest file inside <application /> tag
android:requestLegacyExternalStorage="true"https://github.com/react-native-community/react-native-image-picker/issues/1233#issuecomment-561349254
@kumold Checkout your AndroidManifest.xml and see if it has these lines of code:
+1
From the docs
So you have to obtain WRITE_EXTERNAL_STORAGE using built in react-native permissions or some third party library
You could try following:
It works, but yesterday i got some bugs from production Android 10 devices - user not granted access to photos, even though app pops up alert which asks user to grant it, but either way grant or not i still do not have access to photos. Meybe for older Android we still need android:requestLegacyExternalStorage=“true” property. Could you please tell me what devices you use for develpment (model and system version)?
Could you also tell me what is set in your gradle.build for the following:
Alright, even if it’s just moving the problem somewhere else, if I want to use image-picker correctly, I’ll still have to use requestLegacyExternalStorage…
Add it to
<application>taghello, I am also facing the same problem. When i add camera permission in AndroidManifest file i get the following error
i have added the following permissions
and i have also tried adding
android:requestLegacyExternalStorage="true"inside<application />when i remove<uses-permission android:name="android.permission.CAMERA"/>i get{" errorCode" : "permission"}i want to take the picture and save it on the public storage on my device. so i have addedsaveToPhotos:true,in the options. but when i remove this ‘saveToPhoto:true’ the camera works but according to the documentation that image is stored in the temporary storage and will be removed anytime.do anyone have the solution to the this problem ? my version is
"react-native-image-picker": "^4.3.0",Note: I am getting this error on the physical device during development. i am not using virtual device. Thankyou.