Mediaplugin: Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file

Created on 16 Aug 2018  路  15Comments  路  Source: jamesmontemagno/MediaPlugin

Version Number of Plugin: 4.01.5
Device Tested On: Samsun Glaxy S5
Simulator Tested On:
Version of VS: 2017 Versi贸n 15.8.0
Version of Xamarin:

I have followed follow up all steps of the tutorial for make a simple application, for select one photo of the some directory or Take one Photo, the metod for select the photo works fine but the metod for Take a photo send the error :

Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project.

I noticed that the the code

var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
});

returns the path
"/storage/emulated/0/Android/data/com.companyname.AIAnalizeImage/files/Pictures/temp/images_5.jpeg"

and the code
var file = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
});

returs the path
/storage/extSdCard/Android/data/com.companyname.AIAnalizeImage/files/Pictures

I don't know why the second code returns the route of the external storage "extSdCard" in stead off "emulated".
Some one have some Idea about it, thaks in advance.

Regards.

Most helpful comment

lol, it's our fault. just in case if someone have the same issue check AndroidManifest.xml file android:authorities="${applicationId}.fileprovider" and chage to android:authorities="YOUR_APP_PACKAGE_NAME.fileprovider"

All 15 comments

I have the same issue, this code works fine before. just leave this here for solutions

lol, it's our fault. just in case if someone have the same issue check AndroidManifest.xml file android:authorities="${applicationId}.fileprovider" and chage to android:authorities="YOUR_APP_PACKAGE_NAME.fileprovider"

@apaini my silly mistake.thanks for guiding me

tried the above fix and I am still getting the issue. Any other ideas?

I'm also getting this issue after the fix above

After adding the provider in the manifest, another exception pops up :
Java.Lang.RuntimeException: Unable to get provider com.companyname.Biomasse.FileProvider: java.lang.ClassNotFoundException: Didn't find class "com.companyname.Biomasse.FileProvider" on path: DexPathList[[zip file "/data/app/com.companyname.Biomasse-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.Biomasse-1/lib/x86, /data/app/com.companyname.Biomasse-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]

This is the manifest :

<?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.companyname.Biomasse" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
    <uses-permission android:name="android.permission.CAMERA" />
    <application android:label="Biomasse.Android">
    <provider
      android:name="FileProvider"
      android:authorities="com.companyname.Biomasse.Android.fileprovider">

    </provider>
    </application>
</manifest>

I tried with
android:authorities="com.companyname.fileprovider">
android:authorities="com.companyname.Biomasse.fileprovider">
android:authorities="com.companyname.Biomasse.Android.fileprovider">

with no luck

My bad, this was because I had to add the <meta-data> tag in provider. I used this as a template

can you post the fixed xml @ArthurAttout please?

I threw it away, Xamarin was giving me headaches. I think it was something like

<?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.companyname.AppQ4evo" android:installLocation="preferExternal">
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />
    <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <application android:label="AppQ4evo.Android" android:icon="@drawable/baseline_account_circle_black_18dp">
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.companyname.AppQ4evo.fileprovider" android:grantUriPermissions="true" android:exported="false">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
        </provider>
    </application>
</manifest>

I am still having that issue:(Media plugin version: 4.3.1-beta)
ERROR:Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project.

<application android:icon="@drawable/icon" android:label="Merck">
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="myproject.mypackage.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
        </provider>

i double checked that the file_paths.xml is present in xml folder under resources directory

softsan - did you get this figured out?

Yeh in my case the package name is was different (case sensitivity issue)

i still can not get it to work. I have looked this up and followed everyone of the direction with the same results. Can someone please help me ... this is awful.













error

I had same issue, i downgraded Xam.Plugin.Media version to 4.0.1.5

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdcso picture mdcso  路  4Comments

manonaga2188 picture manonaga2188  路  5Comments

ivmazurenko picture ivmazurenko  路  3Comments

DNF-SaS picture DNF-SaS  路  3Comments

fadaEntrepidus picture fadaEntrepidus  路  6Comments