error CS0234: The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials'
Asked Answered
F

1

5

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?

Federal answered 14/8, 2023 at 14:16 Comment(0)
F
18

Explanation

In the Release Notes for Xamarin.Essentials v1.8.0, they mention that it is now targeting Android 33:

Target MonoAndroid13.0 by @jfversluis in #2087

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 csproj file for your Anrdoid app (typically named *.Droid.csproj or *.Android.csproj), update the <TargetFrameworkVersion> to v13.0:

<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>

AndroidManifest.xml

In AndroidManifest.xml (aka The Android Manifest), update android:targetSdkVersion to "33":

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
Federal answered 14/8, 2023 at 14:16 Comment(2)
It works for 1.8.0, but somehow does not work for 1.8.1.Nobel
The Release notes for v1.8.1 show they've added Android 34 support. Increase your targetSdkVersion to "34" Add API 34/Android 14. github.com/xamarin/Essentials/releases/tag/1.8.1Federal

© 2022 - 2025 — McMap. All rights reserved.