Getting Error: CS0234 The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform' (are you missing an assembly reference?)

Moshe Raab 21 Reputation points
2023-11-22T10:55:00.7566667+00:00

i have a Xamarin App (UWP & Android). The UWP still works, but after upgrading Nuget pacjkages i get the errors shown below. All the errors are in the MainActivity.cs File.

Am I missing a Nuget Package or other reference? If so, which?

Error CS0234: The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform' (are you missing an assembly reference?) in the MainActivity.cs file.

Error CS0234 The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials' (are you missing an assembly reference?)

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

also some like: Error CS1061 'MainActivity' does not contain a definition for 'Assets' and no accessible extension method 'Assets' accepting a first argument of type 'MainActivity' could be found (are you missing a using directive or an assembly reference?)

here are also additional errors (CS0103) of methods that don't exist, such as GetSystemService, NotificationService, StartActivity, AudoService, TabLayoutResource, ToolbarResource, LoadApplication

Error CS1061 'MainActivity' does not contain a definition for 'Assets' and no accessible extension method 'Assets' accepting a first argument of type 'MainActivity' could be found (are you missing a using directive or an assembly reference?)

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,412 questions
{count} votes

Accepted answer
  1. Wheelstring 145 Reputation points
    2023-11-25T15:40:13.4633333+00:00
    Hallo
    
    I had same problem after Visual Studio updated to 17.8
    
    My workaround which fix problem on my computer: 
    
    I JUST PUT PREVIOUS *.csproj (before update VS/Nuget update) Android.csproj and MAIN csproj back to project
    I don't know why, but it's work :-)
    
    
    Android.csproj (after update)
        <PackageReference Include="Xamarin.Essentials">
          <Version>1.8.0</Version>
        </PackageReference>
        <PackageReference Include="Xamarin.Forms">
          <Version>5.0.0.2622</Version>
        </PackageReference>
    
    Android.csproj (before update)
        <PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
        <PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
    
    MAIN csproj (after update)
        <PackageReference Include="Xamarin.Essentials" Version="1.8.0" />
        <PackageReference Include="Xamarin.Forms" Version="5.0.0.2622" />
    
    MAIN csproj (before update)
        <PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />  
        <PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
    
    
    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Moshe Raab 21 Reputation points
    2023-11-23T09:30:36.2733333+00:00

    i think the step that i did was manage NuGets and updated some of them. i did not make any code changes

    so far i have

    • deleted bin and obj folders (also cleaned the builds)
    • repaired and updated VS 2022
    • restored a previous version of the code from GIT