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
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:
Because there was already a reference to Mono.Android.dll, the intellisense couldn't tell there was an issue.
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.