using Xamarin.Forms.Xaml;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Essentials;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]
看来最后一行的代码不起作用,但是在阅读此&GT之后; 。它指出,我要添加的只是我汇编文件文件的最后一行。不确定如何修复它。它指出IM需要为任何Android设备添加最后一行。但是,看来它没有识别使用perpermission。我该如何解决?
这是实际错误:
错误CS0246找不到类型或名称名称“ usePermissionAttribute”(您是否缺少使用指令或汇编引用?)
using Xamarin.Forms.Xaml;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Essentials;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]
It seems the last line of code is not working, however after reading this > https://learn.microsoft.com/en-us/xamarin/essentials/vibrate?tabs=android. It states that all I have to add is the last line to my AssemblyInfo.cs file. Not sure how to fix it. It states that im required to add the last line for any android device. However it seems that it does not recognize the UsesPermission. How can I fix this?
Here is the actual error:
Error CS0246 The type or namespace name 'UsesPermissionAttribute' could not be found (are you missing a using directive or an assembly reference?)
发布评论
评论(1)
您缺少对android.app namespace的引用 - usepermissionAttribute 在其中。尝试使用android.app; 添加
。
You are missing reference to Android.App namespace - UsesPermissionAttribute is in there. Try adding
using Android.App;
.