Config file does not add uses-permission to manifest.xm file

My Android_30 application write file to the storage uses-permission to write on external storage was added to the config file correctly but does not appear on manifest file. Also no error reported on logfile and application does not write the file. Cordova-plug in is used with android

Permissions have changed pretty drastically in recent years. Can you provide your entire config.xml?

Here is the config.xml.

<?xml version='1.0' encoding='utf-8'?>

<widget id="com.voltbuilder.sample" xmlns="http://www.w3.org/ns/widgets" version="0.42">
  <name>Hose4</name>
  <description>Hose_Selection_ app.</description>
  <content src="index.html" />
<icon src="/www/images/logo_E.png" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<preference name="android-targetSdkVersion" value="35" />
   <platforms>
        <platform name="android" />
    </platforms>
  <access origin="*" />
</widget>

If I change sdkVersion=29 it gives build error. Apps will run on android11 and need to download file to the phone storage.

Thanks for help

Generally file access is handled via a plugin, for example: cordova-plugin-file - npm

I don’t notice a plugin in your config.xml - how are you accessing files?

I add cordova.js within index.html header as javascript link script. Adding cordova-plugin in config.xml gives error as it is added by default in the new voltbuilder update! (as I was told).

You definitely need to use cordova-plugin-file to be accessing files on the local device. There are many instructions here: cordova-plugin-file - npm

The line you need to add to your config.xml looks like this:

<plugin name="cordova-plugin-file" spec="^8.1.3" />

VoltBuilder does not add this by default.

I changed the config.xml by adding the plugin as you recommended but I have the same problem as the compiler uses API target android API35, which does not allow WRITE_EXTERNAL_STORAGE permission. What should I do to store *.csv file generated by my application into Android phone? Please, advice. Thank you

Writing to external storage on Android is not well supported using API 30 and above. Here is an excerpt from the file plugin documentation:

With the introduction of Scoped Storage access to External Storage is unreliable or limited via File APIs. Scoped Storage was introduced in API 29. While existing apps may have the ability to opt out, this option is not available for new apps. On Android API 30 and later, Scoped Storage is fully enforced.

Additionally, Direct File Access is not supported on API 29. This means this plugin cannot access external storage mediums on API 29 devices.

API 30 introduced FUSE which allowed limited access to external storage using File APIs, allowing this plugin to partially work again.

Limited access includes but isn’t limited to:

  • Read only access with appropriate READ_EXTERNAL or READ_MEDIA_* permissions.
  • Read only access is limited to media files, but not documents.
  • Writes are limited to only files owned by your app. Modifying files owned by a third-party app (including an image file created via the camera plugin for example) is not possible via the File API.
  • Not all paths in external storage is writable.

These limitations only applies to external filesystems (e.g. cordova.file.external* paths). Internal filesystems such as cordova.file.dataDirectory path are not imposed by these limitations.

If interfacing with the external file system is a requirement for your application, consider using a MediaStore plugin instead.

Ideally you should be using scoped storage unless there is a strong requirement to use external storage. You may have luck using externalApplicationStorageDirectory or externalDataDirectory. I would strongly encourage you to look at the samples included with the plugin: GitHub - apache/cordova-plugin-file: Apache Cordova File Plugin