Xamarin表单文件提供程序未设置

我目前正在学习Xamarin.Forms。 我目前正在尝试使用Plugin.Media.CrossMedia库实现Camerafunction。

实施如下:

public async Task StartCamera() { await CrossMedia.Current.Initialize(); if (Plugin.Media.CrossMedia.Current.IsTakePhotoSupported && CrossMedia.Current.IsCameraAvailable) { var photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions() { SaveToAlbum=false, SaveMetaData=false}); if (photo != null) return ImageSource.FromStream(() => { return photo.GetStream(); }); else return null; } else { return null; } } 

但是,在执行’TakePhotoAsync’方法时,我收到以下错误。

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.

我试过这个但是没有用。 我的AndroidManifest.xml文件目前看起来像这样。

      

我的意思是我需要在这里声明一些内容,但是我无法找到什么,而且我所遵循的所有教程都没有通过设置文件提供程序来完成任何事情。

有什么建议?

自述文件说:

如果您的应用程序针对Android N(API 24)或更新版本,则必须使用2.6.0+版本。

您还必须添加一些其他配置文件以遵守新的严格模式:

1.)将以下内容添加到标记内的AndroidManifest.xml中:

    

您必须将YOUR_APP_PACKAGE_NAME设置为您的应用包名称!

2.)将一个名为xml的新文件夹添加到Resources文件夹中,并添加一个名为file_paths.xml的新XML文件

添加以下代码:

      

您必须将YOUR_APP_PACKAGE_NAME设置为您的应用包名称!

您可以在以下url阅读更多信息: https : //developer.android.com/training/camera/photobasics.html

在我的情况下,这是因为我把FileProvider放在AndroidManifest.xml文件中的错误位置。 它需要在标签内。