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

Android 13 (SDK 33) Permission Issue #36714

Closed
venukaaventude opened this issue Mar 30, 2023 · 5 comments
Closed

Android 13 (SDK 33) Permission Issue #36714

venukaaventude opened this issue Mar 30, 2023 · 5 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Type: Unsupported Version Issues reported to a version of React Native that is no longer supported

Comments

@venukaaventude
Copy link

Description

Hi,
I am unable to request permission for storage. It always returns {"android.permission.READ_EXTERNAL_STORAGE": "never_ask_again", "android.permission.WRITE_EXTERNAL_STORAGE": "never_ask_again"} whenever I try to ask for permission. I tried everything but still the the permission is not allowed on Android 13, sdk 33.

Your help will be really appreciated.

Thank you.

React Native Version

0.60.6

Output of npx react-native info

System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1 Pro
Memory: 85.36 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.1.0 - /var/folders/xb/vpg5x6bn70j8zj9kq_xl9jv80000gn/T/yarn--1680154755528-0.49562717776096243/node
Yarn: 1.22.19 - /var/folders/xb/vpg5x6bn70j8zj9kq_xl9jv80000gn/T/yarn--1680154755528-0.49562717776096243/yarn
npm: 9.1.2 - /opt/homebrew/bin/npm
Watchman: 2022.11.14.00 - /opt/homebrew/bin/watchman
SDKs:
iOS SDK:
Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
Android SDK:
API Levels: 21, 23, 27, 28, 29, 30, 31, 32, 33
Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.0
System Images: android-31 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.1/14B47b - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.6 => 0.60.6
npmGlobalPackages:
react-native: 0.70.4

Steps to reproduce

  • declare permission issue in manifest file

  • request for storage permission

    const granted = await PermissionsAndroid.request(
    PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
    );
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
    console.log('Storage Permission Granted.');
    } else {
    Alert.alert('Error', 'Storage Permission Not Granted');
    }

  • result

{"android.permission.READ_EXTERNAL_STORAGE": "never_ask_again", "android.permission.WRITE_EXTERNAL_STORAGE": "never_ask_again"}

Snack, code example, screenshot, or link to a repository

Screenshot 2023-03-30 at 11 13 42

Screenshot 2023-03-30 at 11 14 12

@github-actions github-actions bot added the Type: Unsupported Version Issues reported to a version of React Native that is no longer supported label Mar 30, 2023
@github-actions
Copy link

⚠️ Unsupported Version of React Native
ℹ️ It looks like your issue or the example you provided uses an unsupported version of React Native. Due to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please upgrade to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on StackOverflow to get further community support.

@efstathiosntonas
Copy link

efstathiosntonas commented Mar 31, 2023

@venukaaventude asking for these permissions on Android 13 is no longer needed.

More info:
https://stackoverflow.com/a/73630987/2195000

This is how I'm using permissions now:

export const checkAndroidPermission = async () => {
  if (Platform.OS === "android" && Platform.Version < 33) {
    const granted = await PermissionsAndroid.requestMultiple([
      "android.permission.CAMERA",
      "android.permission.WRITE_EXTERNAL_STORAGE"
    ]);
    if (
      granted["android.permission.CAMERA"] !== "granted" ||
      granted["android.permission.WRITE_EXTERNAL_STORAGE"] !== "granted"
    ) {
      throw new Error("Required permission not granted");
    }
  }
};
export const checkAndroidPermissionCameraRoll = async () => {
  if (Platform.OS === "android" && Platform.Version < 33) {
    const granted = await PermissionsAndroid.requestMultiple([
      "android.permission.WRITE_EXTERNAL_STORAGE",
      "android.permission.READ_EXTERNAL_STORAGE"
    ]);
    if (
      granted["android.permission.WRITE_EXTERNAL_STORAGE"] !== "granted" ||
      granted["android.permission.READ_EXTERNAL_STORAGE"] !== "granted"
    ) {
      throw new Error("Required permission not granted");
    }
  }
};

@venukaaventude
Copy link
Author

venukaaventude commented Mar 31, 2023

@efstathiosntonas
thanks for your support.
i figure out the problem we can handle that from AndroidManifest.xml , no need to go to the code level. this is how i fixed that issue

   <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="29" />

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Mar 31, 2023
@neethusathya97
Copy link

Hi

I am using @ionic-native/media-capture pluigin for my react ionic project with capacitor 5. The media capture for video, audio and camera is working fine in Android 12 and below devices and also iOS devices .But for android 13 devices the camera capture is not working.Tried out new permission for media in android manifest as suggested in android documentation still not working.We came to know that the ionic.native was replaced with @awesome-cordova-plugins. We tried this also, but didn't worked.

Permission code added in android.manifest file is given below:-


if any solutions.Please suggest

@Mns9983
Copy link

Mns9983 commented Aug 14, 2023

may be it will help you

No, WRITE_EXTERNAL_STORAGE permission does not work on Android 11 or higher. You need to use the MANAGE_EXTERNAL_STORAGE permission instead¹². You also need to set the maxSdkVersion to 29 or lower in your manifest file³. Alternatively, you can use the MediaStore API to access media files without any permissions⁴.

Source: Conversation with Bing, 14/8/2023
(1) Data and file storage overview | Android Developers. https://developer.android.com/training/data-storage/.
(2) Permission write_external_storage NOT WORKING IN android 11. https://community.appinventor.mit.edu/t/permission-write-external-storage-not-working-in-android-11/[4](https://developer.android.com/about/versions/11/privacy/storage)0747.
(3) WRITE_EXTERNAL_STORAGE when targeting Android 10. https://stackoverflow.com/questions/64221188/write-external-storage-when-targeting-android-10.
(4) Storage updates in Android 11 | Android Developers. https://developer.android.com/about/versions/11/privacy/storage.
(5) Saving files in Android 11 to external storage(SDK 30). https://stackoverflow.com/questions/65637610/saving-files-in-android-11-to-external-storagesdk-30.
(6) Permission Denied Issue in Android 11(R) - Stack Overflow. https://stackoverflow.com/questions/61790373/permission-denied-issue-in-android-11r.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Type: Unsupported Version Issues reported to a version of React Native that is no longer supported
Projects
None yet
Development

No branches or pull requests

4 participants