When updating to Xamarin.Essentials v1.8.0, my Android builds fail with the following error:
error CS0234: The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials'
I checked the Xamarin.Essentials source code and confirmed that the Xamarin.Essentials.Platform class does still exist.
The only thing I've changed is to update the Xamarin.Essentials NuGet package from v1.7.7 to v1.8.0. It's not a major release, so there shouldn't be any breaking changes to my app. Is there something wrong with this build / release of Xamarin.Essentials?
Explanation
In the Release Notes for Xamarin.Essentials v1.8.0, they mention that it is now targeting Android 33:
Solution
This means that to use Xamarin.Essentials, you now need to be targeting Android API 33 in your Xamarin.Android app, and there are two files we must update to fix this:
Xamarin.Android CSPROJ
In the
csprojfile for your Anrdoid app (typically named*.Droid.csprojor*.Android.csproj), update the<TargetFrameworkVersion>tov13.0:AndroidManifest.xml
In
AndroidManifest.xml(aka The Android Manifest), updateandroid:targetSdkVersionto"33":