skip to Main Content

I have launced a c# xamarin.forms project that I haven’t used for a while and Visual Studio is saying that the using Android.App is not found. The Android namespace has the red underline. This was working the last time I used it and now it’s giving this error. The code that was using this was the Application(Icon…):

using Android.App;
using Xamarin.Forms.Xaml;

[assembly: Application(Icon = "@drawable/icon")]
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

How can I get the Android namespace into my project? Is it related to the SDK’s? Android SDK Platform 34 is showing as installed in Visual Studio. Visual studio suggests adding a reference to mono.android.dll, but there is already a reference. I’m just not sure if this is an issue with it using the wrong version, or I have some corrupt file in the project (I have pulled the repo to another laptop and got the same issue)

The issue is in multiple classes too.

Any help much appreciated

2

Answers


  1. Chosen as BEST ANSWER

    I finally found the answer. The path to Mono.Android.dll is different depending on which version of visual studio you are running

    Project was originally created in VS Professional. Opening in Community on a different machine couldn't find the dll:

    Program FilesMicrosoft Visual Studio**2022Community**Common7IDEReferenceAssembliesMicrosoftFrameworkMonoAndroidv11.0Mono.Android.dll
    

    Because there was already a reference to Mono.Android.dll, the intellisense couldn't tell there was an issue.


  2. You can try to troubleshoot this problem by following the steps below:

    1.recheck if some special class in your solution has a namespace conflict between several libraries.

    2.try to delete the obj folders and bin folders of every platform, then rebuild it.

    3.if this problem persists, try to update your nugets of your solution to the latest version.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search