Quick Links

MediaPlugin Argument Exception Unable to get file location...

Xamarin Forms app for IOS and Android using MediaPlugin.
Only on some android instances this is not working and throwing the exception below.

The Argument Exeception thrown is:

"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."

Since AppCenter has no way of reporting handled exceptions properly, i have only an eventtype and no stacktrace, device info or anything, but my guess is it happens after calling await CrossMedia.Current.TakephotoAsync(...)

The error suggests i have not setup the fileproviders properly, but the fileprovider info is exactly setup as provided in the readme files. It is working on all my Android test devices and emulators.

I'm having the same problem; I've been able to run the sample with no trouble, but copying the code from the Android Manifest, file paths, Main Activity and the exact same code in the button, I'm still having this error. The only other difference I can see is that I'm using Android views instead of x-forms. Could this be the reason I'm having this problem?

@nrb1238 said:@Kevelop, @Charwaka my issue is fixed. for me it is because of case sensitive. package name and android:authorities should be same(with all lowercase) then it is working fine

If there was a problem with that, shouldn't it fail always? The problem is that i have hundreds of installs that work, but just a couple of tens of installs that have this problem... mixed Android versions, mixed device types etc.

My error was a human mistake as well. There where two tags in my Android Manifest, and the provider was in the second one; that's why it was never recognized as added. I found about this error by checking the generated Android Manifest in obj/Debug/android; maybe this could give a hint to anyone else having this problem.

Not sure what you're trying to say here. That stackoverflow post is about someone who has not setup his file_paths.xml correctly according to the mediaPlugin readme. I have. And also, the mediaplugin sample, which is setup correctly, is crashing. If i however remove the path attribute from the external-file-paths tag, i get the exception:

Unhandled Exception:
System.ArgumentException: 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.

So, what is really the problem here, i don't understand. If both the manifest and the file_paths.xml are setup as mentioned in the MediaPlugin readme, it should work, right?

Not sure what you're trying to say here. That stackoverflow post is about someone who has not setup his file_paths.xml correctly according to the mediaPlugin readme. I have. And also, the mediaplugin sample, which is setup correctly, is crashing. If i however remove the path attribute from the external-file-paths tag, i get the exception:

Unhandled Exception:
System.ArgumentException: 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.

So, what is really the problem here, i don't understand. If both the manifest and the file_paths.xml are setup as mentioned in the MediaPlugin readme, it should work, right?

I figured out the problem, it turn out the "YOUR_APP_PACKAGE_NAME.fileprovider" was the problem. I shouldn't set this to random text instead I should based on Package name on Android Properties and now its working fine even without changing file_paths.xml or any file which are described on Plugin doc.

The sample is working fine, but with my app it took hours to figure out and trying different solutions.
What did it for me is changing path to "." in the xml file<?xml version="1.0" encoding="utf-8" ?><paths><external-files-path name="my_images" path="." /></paths>