Forum Xamarin.Android

The name 'PermissionsImplementation' does not exist in the current context

This problem popped up in my Xamarin project when I updated my visual studio. To isolate it, I created a new [Blank] Xamarin test project to see if it exists with nothing else going on.

I installed the Plugin.Permissions using Nuget. Then added the code as specified by https://github.com/jamesmontemagno/PermissionsPlugin

My MainActivity.cs now looks like:

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace TestApp1.Droid
{
    [Activity(Label = "TestApp1", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
            LoadApplication(new App());
        }

        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);
        }
  }

}

And I get the compiler error: "The name 'PermissionsImplementation' does not exist in the current context"

Best Answer

  • mmandtmmandt Member ✭✭
    Accepted Answer

    I shut down visual studio then went and deleted the 'packages' folders and then the 'bin' and 'obj' folders in the Android directory. Restarted the IDE and that finally resolved the issue

Answers

  • mmandtmmandt Member ✭✭

    OK, update. The problem sample project I created to recreate this issue can be solved by putting in
    using Plugin.Permissions;

    However, that is already in my main project and does not work. All I can figure is that the main project is somehow corrupted?

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    However, that is already in my main project and does not work.

    Your project could build success but can't request permission at runtime? Have you install the Current Activity Plugin as the document said?

    All I can figure is that the main project is somehow corrupted?

    Could u please elaborate a bit more?

  • mmandtmmandt Member ✭✭

    Your project could build success but can't request permission at runtime?

    The main project can't build successfully. No. I get the compiler error: "The name 'PermissionsImplementation' does not exist in the current context"

    Yes, I have installed the Current Activity Plugin.

    All I can figure is that the main project is somehow corrupted?

    If I create a new project and install the Plugin.Permissions, there is no problem. While, on the other hand, with my actual project, it clearly does not work. The libraries are not properly linking and being recognized the way that they should be.

  • mmandtmmandt Member ✭✭
    Accepted Answer

    I shut down visual studio then went and deleted the 'packages' folders and then the 'bin' and 'obj' folders in the Android directory. Restarted the IDE and that finally resolved the issue

  • I have exactly the same issue since updating VS ans I just cannot get rid of the error.

    I've tried deleting the Android project bin & obj folders, clearing the nuGet cache, etc and I just cannot resolve this issue at all. Prior to updating VS everything was building fine but now I can't build my Android project at all :s

    Any other ideas folks?

Sign In or Register to comment.