skip to Main Content

I’m facing an issue with my React Native app where camera and file access permissions are not being granted on Android 14, even though I’ve allowed the permissions in the settings. The permissions are working fine on previous versions of Android, but not on Android 14.

I have already modified my AndroidManifest.xml as follows:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

But despite these changes, I still see the "Permissions not granted" warning for camera and file access on Android 14.

Has anyone encountered a similar issue or can suggest a solution?

Thanks in advance!

2

Answers


  1. The INTERNET permission is classified as a normal permission, which means it is automatically granted at install time and does not require explicit user approval at runtime.
    But, that is needed for other permission types . Such as for camera you have to make sure to follow the following steps ,

    • Declare camera permissions in AndroidManifest.xml. ( which you did )

    • Request camera permission at runtime using PermissionsAndroid or
      expo-camera.

    • Use a library like react-native-camera or expo-camera to access the
      camera.

    • Handle permission denial gracefully.

    Login or Signup to reply.
  2. This worked for me:

    import {PERMISSIONS} from 'react-native-permissions';
    
    const getPermissions = async () => {
    console.log('-=-=-=');
    if (Platform.OS === 'android') {
      try {
        const granted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.CAMERA,
          {
            title: 'App Camera Permission',
            message: 'App needs access to your camera ',
            buttonNeutral: 'Ask Me Later',
            buttonNegative: 'Cancel',
            buttonPositive: 'OK',
          },
        );
        if (granted === PermissionsAndroid.RESULTS.GRANTED) {
          console.log('Camera permission given');
        } else {
          console.log('Camera permission denied');
        }
      } catch (err) {
        console.warn(err);
      }
    } else {
      try {
        PERMISSIONS.IOS.MICROPHONE;
      } catch (err) {
        console.warn(err);
      }
    }
    
    if (Platform.OS === 'android') {
      try {
        const grants = await PermissionsAndroid.requestMultiple([
          PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
          PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
          PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
        ]);
    
        // console.log('write external stroage', grants);
    
        if (
          grants['android.permission.WRITE_EXTERNAL_STORAGE'] ===
            PermissionsAndroid.RESULTS.GRANTED &&
          grants['android.permission.READ_EXTERNAL_STORAGE'] ===
            PermissionsAndroid.RESULTS.GRANTED &&
          grants['android.permission.RECORD_AUDIO'] ===
            PermissionsAndroid.RESULTS.GRANTED
        ) {
          console.log('Permissions granted');
        } else {
          console.log('All required permissions not granted');
          return;
        }
      } catch (err) {
        console.warn(err);
        return;
      }
    }
    
     };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search