Android.Content and Android.Graphics missing an assembly reference?

I have just update Xamarin VS and have a project which has not changed since Oct 2015, and has been successfully compiling and happy all this time. I am now getting two errors when trying to compile the project.

Error   6   The type or namespace name 'Content' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?) e:\Workspaces\Code Examples\Xamarin\Xamarin.Auth-master\src\Xamarin.Auth\AccountStore.cs    44  46  Xamarin.Auth.Android
Error   7   The type or namespace name 'Graphics' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)    E:\Workspaces\Code Examples\Xamarin\Xamarin.Auth-master\src\Xamarin.Auth.Android\WebAuthenticatorActivity.cs    165 74  Xamarin.Auth.Android

I have tried clean, build, deleting the bin folder, rebuild, creating a new empty project and adding all the files and still get errors. If I type Android. - Intellisense only gives me the option for Android.Net and nothing else. I can correct the errors by adding Using Android.Content at the top instead of using the full name of
public static AccountStore Create (Android.Content.Context context)

And
public override void OnPageStarted (WebView view, string url, Android.Graphics.Bitmap favicon)

Have I missed a change, or do I need to do something more than a clean and rebuild?

Tagged:

Posts

  • shauryamadshauryamad USMember

    I was able to solve the error with the link provided.

    Error 7 The type or namespace name 'Graphics' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)

    But how do we solve the error

    Error 6 The type or namespace name 'Content' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)

    The link below does not help solve the problem. Please provide any information about how to resolve the error.

    Thankyou

  • shauryamadshauryamad USMember

    Is there anyone who can answer this question for me?

  • SHIVANKUCHAUHANSHIVANKUCHAUHAN USMember ✭✭✭

    @JamesBaldwinson
    1. Clean the solution
    2. Build the PCL
    3. Remove the PCL reference from the affected project(s)
    4. Re-add the PCL reference
    5. Build
    This also happens sometimes after opening a XAML file and switching back to a C# file in the PCL project.

  • RofiqSetiawanRofiqSetiawan USMember ✭✭✭

    @shauryamad said:
    I was able to solve the error with the link provided.

    Error 7 The type or namespace name 'Graphics' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)

    But how do we solve the error

    Error 6 The type or namespace name 'Content' does not exist in the namespace 'Xamarin.Android' (are you missing an assembly reference?)

    The link below does not help solve the problem. Please provide any information about how to resolve the error.

    Thankyou

    your namespace contains Android string. maybe it's confusing Xamarin.
    rename your namespace likes Xamarin_Android , XamarinAndroid, XamDroid. It's up to you btw

    another solution is you have to write complete Type with its complete namespace, eg:

    var blue = Android.Graphics.Color.Blue;  \\ or global::Android.Graphics.Color.Blue;
    

    instead

    var blue = Color.Blue;
    
  • LijoCJLijoCJ USMember ✭✭
    edited August 2017

    In a custom renderer I had error "The type or namespace name 'Graphics' does not exist in the namespace". The error was on the following line.

     p.SetColor(Color.Rgb(0x70, 0xb2, 0x3f));
    

    The reason was strange. I had a using statement for Xamarin.Forms. So, it was not able to use Android.Graphics.Color.

    Removing the using statement for Xamarin.Forms fixed the problem for me.

  • NickKovalskyNickKovalsky USMember ✭✭✭

    Can happen when you try to use Android.Content and similar inside a namespace like Yournamespace.Android - ending with "Android".
    Rename it to Yournamespace.Droid the error will be gone.

Sign In or Register to comment.