Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Mediaplugin Fileprovider

I'm trying to implement the MediaPlugin but I am running into a problem. I have done all steps in the setup instructions and get the following error:

Error: No resource found that matches the given name (at 'resource' with value '@xml/file_paths')

As explained in the setup instructions - in my Android project, I have added a folder inside the Resources-folder, called xml - containing a file called file_paths.xml with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="my_images" path="Pictures" />
<external-files-path name="my_movies" path="Movies" />
</paths>

I expect this problem to be related to either the above or the AndroidManifest.xml, so I'll include my complete AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.company.Kvitt" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="15" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <application android:label="Kvitt.Android">
        <provider android:name="android.support.v4.content.FileProvider"
                  android:authorities="com.company.Kvitt.fileprovider"
                  android:exported="false"
                  android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
                       android:resource="@xml/file_paths"/>
        </provider>
    </application>
</manifest>

Any help or ideas on how to solve this error are really appreciated!

like image 570
Thomas D. Frøysa Avatar asked Mar 09 '18 00:03

Thomas D. Frøysa


1 Answers

The res/xml directory should be in the same sub-folder as other Resources; drawable, layout, mipmap-XXX, etc...

  • Do a clean all / build all just as a double check
  • Double-check your xml path in the project: Resources/xml/file_paths.xml
  • After a build, check the build artifacts for the file in obj/Debug/android/res/xml

If the resource file is not in the build artifacts the likely cause is the build action is wrong

  • Check that the build action on the file is set to AndroidResource
like image 128
SushiHangover Avatar answered Jan 04 '23 00:01

SushiHangover