在xamarin.forms中使用Plugin.Permissions时出现此错误:
无法解析引用:MyProject引用的Plugin.Permissions。请为Plugin.Permissions添加NuGet程序包或程序集引用,或删除对MyProject的引用。 MyProject.Android
但是我在所有项目(Forms,android,ios)中添加了plugin.permission
答案 0 :(得分:0)
我在MainActivity中添加了此方法:
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
,并在以下行的base.OnCreate(savedInstanceState)之后添加:
protected override void OnCreate(Bundle savedInstanceState)
{
var intent = new Intent(this, typeof(MainService));
StartService(intent);
layout = FindViewById<LinearLayout>(Resource.Layout.AlertActivity);
Log.Debug("StartService", "DemoService started");
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
//this line added
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this,
savedInstanceState);
Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
现在,一切正常! 谢谢您的帮助!