Cordova Plugin File doesn't work on Android 13 #424
-
Good morning! What permission should I add to be able to write a .CSV file in the "Documents" folder ? I've tried all the permissions below. I got this error: "onErrorGetDir". The folder is: file:///storage/emulated/0/ Remember, this works fine on others versions, like Android 11 or below. Android 12 I haven't tested yet, but it seems to work ! Thank you for now ! |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 23 replies
-
Android's external file system is now quite limiting and doesn't allow direct file access via file APIs for all files anymore. It does allow for media files such as images, videos, audio. For other file types, the native MediaStore API needs to be used, which the file plugin does not use (and it's not really a file API so it's going to be hard to facade it to make it look like a file API).
This wouldn't have worked since Scoped Storage, which was introduced in API 29, but existing apps could opt out and revert back to legacy filesystem. Starting API 30, the scoped storage is fully enforced. The short answer, if you need external storage access, you'd be probably better off using a plugin that actually interfaces with the native MediaStore API such as cordova-plugin-saf-mediastore (not an endorsement, never used it myself, and you may want to check the license cause it's not a license I'm familiar with). The filesystem works well with internal storage (e.g. apps own data directory). I'm not sure if the filesystem plugin can be updated to use the MediaStore API while keeping it's old API signature, so support for external storage may just drop entirely altogether. These are my own thoughts however, and this hasn't been brought up for a community discussion yet on the mailing list. |
Beta Was this translation helpful? Give feedback.
-
Do you have any tips for opening a file browser so that the user can choose where to save the content ? The content would be generated by the app. |
Beta Was this translation helpful? Give feedback.
-
I made the implementation of plugin... ... and I got this error when doing the build. This is because the class of line 21 doesn't exists Am I doing the import of Java Class correctly ? |
Beta Was this translation helpful? Give feedback.
-
Hi, I have the same problem with cordova-plugin-saf-mediastore like leonelgregioauler had. Solution with Solution with My project is Quasar 2.12.6 app. I'm using cordova-android 12.0.1, java SDK 11, gradle 7.4.2. Could you please give me some suggestions what im doing wrong and what should I do? This cordova-plugin-saf-mediastore plugin seems something "fresh" and there are no many sources about it even in the universe of internet :-) Thanks in advance and have a nice day |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for response. I made check with I think Qusar has no negative impact on build but I can't be sure.
and after some lines in terminal this appear:
If you will have any idea what to do please let me know. Best regards |
Beta Was this translation helpful? Give feedback.
-
Hello ! build.gradle exists in 2 folders. The correct file is in this path: hybrid/platforms/android/app Review this path, please ! |
Beta Was this translation helpful? Give feedback.
-
Hello leonelgregioauler I can't find hybrid/platforms/android/app folder in my project. There are others build.gradle files in node_modules but I think they are not important (hope im right). |
Beta Was this translation helpful? Give feedback.
Android's external file system is now quite limiting and doesn't allow direct file access via file APIs for all files anymore. It does allow for media files such as images, videos, audio. For other file types, the native MediaStore API needs to be used, which the file plugin does not use (and it's not really a file API so it's going to be hard to facade it to make it look like a file API).
This wouldn't have worked since Scoped Storage, which was introduced in API 29, but existing apps could opt out and revert back to legacy filesystem. Starting API 30, the sco…