Currently I am updating my Xamarin project to MAUI.
Now I have trouble with the Android File Provider Path File.
In the Manifest.xml I set
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@values/file_paths"></meta-data>
</provider>
Under “Platforms/Android/Resources/values” I created a file called “file_paths.xml”
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="my_images" path="/images" />
</paths>
Build-Action – AndroidResource
When I build the project I get this error:
Resources/values/file_paths.xml(2): error APT2230: root element must be <resources>.
VisualStudio for Mac 17.6.14
.NET8
As the error message said: root element must be <resources>
Make sure you have your resource file with a <resources>
tag as root element.
Please refer to this sample resource file from MAUI project template:
App/Platforms/Android/Resources/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
1