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

bug: READ_EXTERNAL_STORAGE Deprecated: File Access Fails on Android 13+ in Capacitor Ionic App #351

Open
5 of 28 tasks
tarektaamali opened this issue Dec 13, 2024 · 1 comment

Comments

@tarektaamali
Copy link

Plugin(s)

  • Android Foreground Service
  • Android Battery Optimization
  • App Review
  • App Update
  • Background Task
  • Badge
  • Bluetooth Low Energy
  • Cloudinary
  • Datetime Picker
  • File Compressor
  • File Opener
  • File Picker
  • Live Update
  • Managed Configurations
  • NFC
  • Photo Editor
  • Printer
  • Screen Orientation
  • Speech Recognition
  • Speech Synthesis
  • Torch
  • Zip

Version

6.0.1

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

As stated in the plugin documentation, to pick a file from external storage, the following permission is required:


<!-- Needed if you want to read files from external storage -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

However, READ_EXTERNAL_STORAGE is deprecated and not granted when targeting Android 13+. If you need to query or interact with MediaStore or media files on shared storage, you should use one or more of the new storage permissions instead:

android.permission.READ_MEDIA_IMAGES
android.permission.READ_MEDIA_VIDEO
android.permission.READ_MEDIA_AUDIO

Scoped storage is enforced on Android 10+ (or Android 11+ if requestLegacyExternalStorage is used). Specifically, WRITE_EXTERNAL_STORAGE no longer provides write access to all files but instead provides functionality equivalent to READ_EXTERNAL_STORAGE.

Expected behavior

Apps are restricted to accessing only the media files (e.g., images, videos, or audio) that the user explicitly allows through the newly introduced permissions:

READ_MEDIA_IMAGES: Grants read access only to image files in the shared storage.
READ_MEDIA_VIDEO: Grants read access only to video files in the shared storage.
READ_MEDIA_AUDIO: Grants read access only to audio files in the shared storage.

Reproduction

https://capawesome.io/plugins/file-picker/

Steps to reproduce

ionic start exampleApp blank --type=angular
cd exampleApp
npm install @capacitor/core @capacitor/cli
npm install
npx cap add android

Other information

No response

Capacitor doctor

[warn] The bundledWebRuntime configuration option has been deprecated. Can be safely deleted.
Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2

[success] Android looking great! 👌

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
Copy link
Contributor

This issue has been labeled as needs: reproduction. This label is added to issues that need a code reproduction.

Please provide a Minimal, Reproducible Example using this template in a public GitHub repository so we can debug the issue.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for us to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants