MediaPlugin Argument Exception Unable to get file location...

KevelopKevelop NLMember ✭✭

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.

My file_paths.xml file:

<?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>

And this is set in the AndroidManifest.xml:

<manifest...>
        <application...>
            <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.myappname.nl.fileprovider" android:exported="false" android:grantUriPermissions="true">
                    <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
                </provider>
        </application>
    </manifest>

What can be wrong on the problematic instances?

Best Answer

Answers

  • nrb1238nrb1238 USMember ✭✭

    @charwaka, same issue after adding the line also

    @Kevelop

    Did you find the solution?

  • KevelopKevelop NLMember ✭✭
    @Charwaka @nrb1238 I have that line as well. It is not the solution unfortunately
  • CharwakaCharwaka INMember ✭✭✭✭✭

    @Kevelop said:
    @Charwaka @nrb1238 I have that line as well. It is not the solution unfortunately

    Try this Sample And tell me its working or not

    https://github.com/jamesmontemagno/MediaPlugin/tree/master/samples

  • KevelopKevelop NLMember ✭✭
    > @Charwaka said:
    > @Kevelop said:
    > @Charwaka @nrb1238 I have that line as well. It is not the solution unfortunately
    >
    >
    >
    >
    >
    > Try this Sample And tell me its working or not
    >
    > https://github.com/jamesmontemagno/MediaPlugin/tree/master/samples

    I can't reproduce the error locally. It's happening in the field. So I was hoping someone figured out what could cause it, because I can't yet
  • cbinceptiocbinceptio Member ✭✭

    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?

  • nrb1238nrb1238 USMember ✭✭

    @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

  • KevelopKevelop NLMember ✭✭

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

  • cbinceptiocbinceptio Member ✭✭

    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.

  • KevelopKevelop NLMember ✭✭

    @Charwaka I managed to reproduce the error. Even the sample from MediaPlugin itself crashes!

    To reproduce you have to switch the default from Internal memory to SD card from within the Android settings.
    After that, it crashes before you can even take a picture!

    (@JamesMontemagno : Do you have any idea how to resolve this? )

    See stacktrace:

    Java.Lang.IllegalArgumentException: Failed to find configured root that contains /storage/3132-3031/Android/data/com.plugin.mediatest/files/Pictures/Test/IMG_20180201_092724.jpg
    
    02-01 09:27:31.246 I/MonoDroid(12993): UNHANDLED EXCEPTION:
    02-01 09:27:31.304 I/MonoDroid(12993): Java.Lang.IllegalArgumentException: Failed to find configured root that contains /storage/3132-3031/Android/data/com.plugin.mediatest/files/Pictures/Test/IMG_20180201_092724.jpg
    02-01 09:27:31.304 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <54816278eed9488eb28d3597fecd78f8>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in <b45497bae7b44aa5b84d9841d4f92a20>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Android.Support.V4.Content.FileProvider.GetUriForFile (Android.Content.Context context, System.String authority, Java.IO.File file) [0x00077] in <dc495abdac154ae3bea326f4da3a4ec0>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Plugin.Media.MediaPickerActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0023f] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaPickerActivity.cs:162 
    02-01 09:27:31.305 I/MonoDroid(12993): --- End of stack trace from previous location where exception was thrown ---
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at Plugin.Media.MediaImplementation+<TakePhotoAsync>d__17.MoveNext () [0x000c8] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaImplementation.cs:153 
    02-01 09:27:31.305 I/MonoDroid(12993): --- End of stack trace from previous location where exception was thrown ---
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at MediaSample.MediaPage+<<-ctor>b__0_0>d.MoveNext () [0x000ba] in C:\Users\kevin\Downloads\MediaPlugin-master\MediaPlugin-master\samples\MediaSample\MediaSample\MediaPage.xaml.cs:27 
    02-01 09:27:31.305 I/MonoDroid(12993): --- End of stack trace from previous location where exception was thrown ---
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <b45497bae7b44aa5b84d9841d4f92a20>:0 An unhandled exception occured.
    
    
    02-01 09:27:31.305 I/MonoDroid(12993):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <b45497bae7b44aa5b84d9841d4f92a20>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <b45497bae7b44aa5b84d9841d4f92a20>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at (wrapper dynamic-method) System.Object:a7718712-90ff-465b-94ab-3d1ab764d5ea (intptr,intptr)
    02-01 09:27:31.305 I/MonoDroid(12993):   --- End of managed Java.Lang.IllegalArgumentException stack trace ---
    02-01 09:27:31.305 I/MonoDroid(12993): java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/3132-3031/Android/data/com.plugin.mediatest/files/Pictures/Test/IMG_20180201_092724.jpg
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400)
    02-01 09:27:31.305 I/MonoDroid(12993):  at md55b01af31820394fbfb172542d1258596.MediaPickerActivity.n_onCreate(Native Method)
    02-01 09:27:31.305 I/MonoDroid(12993):  at md55b01af31820394fbfb172542d1258596.MediaPickerActivity.onCreate(MediaPickerActivity.java:42)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.Activity.performCreate(Activity.java:6910)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.ActivityThread.-wrap12(ActivityThread.java)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.os.Handler.dispatchMessage(Handler.java:102)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.os.Looper.loop(Looper.java:156)
    02-01 09:27:31.305 I/MonoDroid(12993):  at android.app.ActivityThread.main(ActivityThread.java:6523)
    02-01 09:27:31.305 I/MonoDroid(12993):  at java.lang.reflect.Method.invoke(Native Method)
    02-01 09:27:31.305 I/MonoDroid(12993):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
    02-01 09:27:31.305 I/MonoDroid(12993):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
    02-01 09:27:31.305 I/MonoDroid(12993):  
    
  • CharwakaCharwaka INMember ✭✭✭✭✭

    @Kevelop said:
    @Charwaka I managed to reproduce the error. Even the sample from MediaPlugin itself crashes!

    To reproduce you have to switch the default from Internal memory to SD card from within the Android settings.
    After that, it crashes before you can even take a picture!

    (@JamesMontemagno : Do you have any idea how to resolve this? )

    See stacktrace:

    Java.Lang.IllegalArgumentException: Failed to find configured root that contains /storage/3132-3031/Android/data/com.plugin.mediatest/files/Pictures/Test/IMG_20180201_092724.jpg
    
    02-01 09:27:31.246 I/MonoDroid(12993): UNHANDLED EXCEPTION:
    02-01 09:27:31.304 I/MonoDroid(12993): Java.Lang.IllegalArgumentException: Failed to find configured root that contains /storage/3132-3031/Android/data/com.plugin.mediatest/files/Pictures/Test/IMG_20180201_092724.jpg
    02-01 09:27:31.304 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <54816278eed9488eb28d3597fecd78f8>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in <b45497bae7b44aa5b84d9841d4f92a20>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Android.Support.V4.Content.FileProvider.GetUriForFile (Android.Content.Context context, System.String authority, Java.IO.File file) [0x00077] in <dc495abdac154ae3bea326f4da3a4ec0>:0 
    02-01 09:27:31.304 I/MonoDroid(12993):   at Plugin.Media.MediaPickerActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0023f] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaPickerActivity.cs:162 
    02-01 09:27:31.305 I/MonoDroid(12993): --- End of stack trace from previous location where exception was thrown ---
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at Plugin.Media.MediaImplementation+<TakePhotoAsync>d__17.MoveNext () [0x000c8] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaImplementation.cs:153 
    02-01 09:27:31.305 I/MonoDroid(12993): --- End of stack trace from previous location where exception was thrown ---
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at MediaSample.MediaPage+<<-ctor>b__0_0>d.MoveNext () [0x000ba] in C:\Users\kevin\Downloads\MediaPlugin-master\MediaPlugin-master\samples\MediaSample\MediaSample\MediaPage.xaml.cs:27 
    02-01 09:27:31.305 I/MonoDroid(12993): --- End of stack trace from previous location where exception was thrown ---
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <b45497bae7b44aa5b84d9841d4f92a20>:0 An unhandled exception occured.
    
    
    02-01 09:27:31.305 I/MonoDroid(12993):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <b45497bae7b44aa5b84d9841d4f92a20>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <b45497bae7b44aa5b84d9841d4f92a20>:0 
    02-01 09:27:31.305 I/MonoDroid(12993):   at (wrapper dynamic-method) System.Object:a7718712-90ff-465b-94ab-3d1ab764d5ea (intptr,intptr)
    02-01 09:27:31.305 I/MonoDroid(12993):   --- End of managed Java.Lang.IllegalArgumentException stack trace ---
    02-01 09:27:31.305 I/MonoDroid(12993): java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/3132-3031/Android/data/com.plugin.mediatest/files/Pictures/Test/IMG_20180201_092724.jpg
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400)
    02-01 09:27:31.305 I/MonoDroid(12993):    at md55b01af31820394fbfb172542d1258596.MediaPickerActivity.n_onCreate(Native Method)
    02-01 09:27:31.305 I/MonoDroid(12993):    at md55b01af31820394fbfb172542d1258596.MediaPickerActivity.onCreate(MediaPickerActivity.java:42)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.Activity.performCreate(Activity.java:6910)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.os.Handler.dispatchMessage(Handler.java:102)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.os.Looper.loop(Looper.java:156)
    02-01 09:27:31.305 I/MonoDroid(12993):    at android.app.ActivityThread.main(ActivityThread.java:6523)
    02-01 09:27:31.305 I/MonoDroid(12993):    at java.lang.reflect.Method.invoke(Native Method)
    02-01 09:27:31.305 I/MonoDroid(12993):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
    02-01 09:27:31.305 I/MonoDroid(12993):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
    02-01 09:27:31.305 I/MonoDroid(12993):  
    

    https://stackoverflow.com/questions/42516126/fileprovider-illegalargumentexception-failed-to-find-configured-root

  • KevelopKevelop NLMember ✭✭

    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?

  • CharwakaCharwaka INMember ✭✭✭✭✭

    @Kevelop said:

    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?

    yes ,it should work.have you tested in other Devices ??

  • aridonaridon Member ✭✭
    edited February 2018

    @Kevelop how did you manage the
    <external-path name="my_images" path="Android/data/com.plugin.mediatest/files/Pictures" />
    Is this path general from the Media Plugin or it's depend in our own path?

  • aridonaridon Member ✭✭

    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.

  • DonCB2BDonCB2B USMember ✭✭✭
    edited February 2018

    @Kevelop Thanks. It's working again.

  • Mani787Mani787 INMember ✭✭✭

    @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

    As per your suggestion, i have updated the android attributes. Now its working perfectly for me. Thank you for sharing your input.

  • PatJnrPatJnr USMember

    Just to explain the accepted answer,

    <external-files-path name="my_images" path="Pictures" /> <--------- wrong tag

    <external-path name="my_images" path="Pictures" /> <--------- correct Tag

  • MazidiMazidi Member ✭✭

    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>

    from here found the answer
    stackoverflow.com/a/48008968/10327213

  • BrianBentwoodBrianBentwood USMember ✭✭

    Hi,

    Your issue is that the your AndroidManifest.xml file references 'android:authorities="com.myappname.nl.fileprovider"', but then your app package ID is actually "com.plugin.mediatest".

    If you make them the same, then the first way you had the files_path file would work. I just noticed this on mine and fixed it.

  • MNadeemMNadeem Member ✭✭

    I done it. It's very easy a little bit difference in it
    this one

    var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
    var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

            if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera, Permission.Storage });
                cameraStatus = results[Permission.Camera];
                storageStatus = results[Permission.Storage];
            }
    
            if (cameraStatus == PermissionStatus.Granted && storageStatus == PermissionStatus.Granted)
            {
                var option = await DisplayActionSheet("Photo Action with", null, null, "Take Photo", "Choose from Gallary");
                if (option == "Take Photo")
                {
                    var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
    
                        SaveToAlbum = true,
                        Directory = "Foxy",
                        DefaultCamera = CameraDevice.Front,
                        PhotoSize = PhotoSize.Medium,
                        CompressionQuality = 92
    
                    });
    
                    riderPhotoName = "RiderPhoto.jpg";
                    riderphotoPreview.IsVisible = true;
    
                    riderphotoPreview.Source = ImageSource.FromStream(() => {
                        riderPhotoStream = file.GetStream();
                        return riderPhotoStream;
                    });
    
                    riderPhotoStream = file.GetStream();
                    file.Dispose();
                }
                else
                {
                    var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { });
    
                    riderPhotoName = "RiderPhoto.jpg";
                    riderphotoPreview.IsVisible = true;
    
                    riderphotoPreview.Source = ImageSource.FromStream(() => {
                        riderPhotoStream = file.GetStream();
                        return riderPhotoStream;
                    });
    
                    riderPhotoStream = file.GetStream();
                    file.Dispose();
                }
            }
            else
            {
                await DisplayAlert("Permissions Denied", "Unable to take photos.", "OK");
                CrossPermissions.Current.OpenAppSettings();
            }
    
  • nlivninlivni Member

    Any update on this? I am having the same problem and all the potential solutions in this thread are not working.

  • nlivninlivni Member
    edited February 7

    I solved it. For me the problem was that:

    <provider android:name="android.support.v4.content.FileProvider"
                android:authorities="${applicationId}.fileprovider"
                android:exported="false"
                android:grantUriPermissions="true">
    
       <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
    </provider>
    

    was not nested in the <manifest> tag instead of under the <application> tag where it belongs

  • anderson_Smauganderson_Smaug Member ✭✭

    Make sure the name of the project is in agreement with the manifesto I touched the name of the project and ended up falling on this problem.


        </provider>
    
  • anderson_Smauganderson_Smaug Member ✭✭

    Make sure the name of the project is in agreement with the manifesto I touched the name of the project and ended up falling on this problem.

    manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.7.2" package="ProjectName" android:versionCode="33"

    provider android:name="android.support.v4.content.FileProvider" android:authorities="br.com.eaglelog.eaglelog.fileprovider" android:exported="false" android:grantUriPermissions="true"
    meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /meta-data

        provider
    
  • anderson_Smauganderson_Smaug Member ✭✭

    @anderson_Smaug said:
    Make sure the name of the project is in agreement with the manifesto I touched the name of the project and ended up falling on this problem.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.7.2"

    package="ProjectName" android:versionCode="33">

    <provider android:name="android.support.v4.content.FileProvider" android:authorities="ProjectName"

    android:exported="false" android:grantUriPermissions="true">

          <meta-data android:name="android.support.FILE_PROVIDER_PATHS"    
    

    android:resource="@xml/file_paths">;


  • anderson_Smauganderson_Smaug Member ✭✭

    @anderson_Smaug said:
    @anderson_Smaug said:
    Make sure the name of the project is in agreement with the manifesto I touched the name of the project and ended up

    falling on this problem.
    >






Sign In or Register to comment.