react-native-cameraroll: Getting permission denied error on Android after I have inlcuded permissions in AndroidManifest.xml
I have already included the following permissions in my AndroidManifest.xml
:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
However after I call CameraRoll.saveToCameraRoll(Platform.OS === 'ios' ? this.props.imageItem.url : this.state.imageUri);
I’m still getting the following permission error:
03-28 15:50:22.567 13354 13395 W ReactNativeJS: Possible Unhandled Promise Rejection (id: 0):
03-28 15:50:22.567 13354 13395 W ReactNativeJS: Error: Permission denied
03-28 15:50:22.567 13354 13395 W ReactNativeJS: createErrorFromErrorData@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2012:26
03-28 15:50:22.567 13354 13395 W ReactNativeJS: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:1964:51
03-28 15:50:22.567 13354 13395 W ReactNativeJS: __invokeCallback@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2531:23
03-28 15:50:22.567 13354 13395 W ReactNativeJS: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2262:34
03-28 15:50:22.567 13354 13395 W ReactNativeJS: __guard@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2435:15
03-28 15:50:22.567 13354 13395 W ReactNativeJS: invokeCallbackAndReturnFlushedQueue@http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:2261:21
03-28 15:50:22.567 13354 13395 W ReactNativeJS: invokeCallbackAndReturnFlushedQueue@[native code]
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (3 by maintainers)
@ethanyuwang the thing is that you have to explicitly ask for the permission. Adding them to the manifest is just a way to list all the permission you’re going to be asking inside the app.
You can solve this easily with something like this:
Hope it helps 😸
https://github.com/react-native-community/react-native-cameraroll/issues/219#issuecomment-671411010
@dmevt this fixed the problem for me, thanks!
I have the same issue. I am using react-native-view-shot and @react-native-community/cameraroll to capture the screenshot and save it on the external storage. But I always get the permission denied error in Android. I have tried all the method above, but the same. I have checked the permission status with PermissionAndroid and it said ‘granted’. But I can’t save the screenshot with the error: ‘Permission denied’. Which permissions are more needed? Please help me. Android version is 29.
Can we have this on the documentation?
downloaded new version now it is working properly
Yeah, after doing what is described here it worked. It would be nice to have this on the docs, though.
@joseguerrerov will like to know if the permission function will be required for ios. Also when I followed your procedure for android… I get something like this in return
content://media/external_primary/file/92336
And I cannot see the image in the android gallery … will like to know if there is any other thing to do.