How to give path to Download directory in environment variable of AndroidEnvironment build file

Viewed 373

Using Visual Studio 2022 17.2.0 Preview 1.0 I am currently trying to create a MAUI app that already runs fine with Windows to also run under Android.

The app uses a library (SaxonCS 11) which needs to read its license file from a directory that can be given in an environment variable SAXON_LICENSE_DIR.

For Android, I have found I can add a .txt file to my project with the build action AndroidEnvironment to define environment variables.

However, I struggle to find the right value for the SAXON_LICENSE_DIR variable to point to a directory that the C# code can read.

In the Android emulator phone I put the file into the Download folder which the Files app shows me to be in the folder sdk_gphone_x86_64 so I have for instance tried to set the variable to SAXON_LICENSE_DIR=/sdk_gphone_x86_64/Download.

When I have added the <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> to my AndroidManifest.xml that directory doesn't give me an access denied directory like other attempts like SAXON_LICENSE_DIR=/storage/emulated/0/Download but the file is not read/found.

I guess relying on that particular emulator's directory sdk_gphone_x86_64 is not a compatible form anyway, so my question is: how would I set an environment variable to point to the Download directory of the user on the Android phone so that C#/MAUI code can use that path to read out a directory in that directory?

C# code does nothing more like static private Processor processor = new Processor(); which seems to have SaxonCS Processor try to look correctly for saxon-license.lic in the path given in SAXON_LICENSE_DIR but throws an exception

Saxon.Hej.trans.LicenseException
  message = Failed to read license file /sdk_gphone_x86_64/Download/saxon-license.lic
0 Answers
Related