xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 506 forks source link

[Bug] [Android] [Regression] 1.8.0 Android assembly doesn't appear to contain Xamarin.Essentials.Platform #2097

Closed mfeingol closed 11 months ago

mfeingol commented 11 months ago

Description

Steps to Reproduce

  1. Upgrade Xamarin Forms app using Xamarin Essentials 1.7.7 to 1.8.0
  2. Build Android project
  3. Observer build errors

Expected Behavior

No API changes

Actual Behavior

1>C:\Operations\Build\Home\Sideroads\Source\Sideroads.Xamarin\Sideroads.Android\MainActivity.cs(138,13,138,40): error CS0234: The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials' (are you missing an assembly reference?) 1>C:\Operations\Build\Home\Sideroads\Source\Sideroads.Xamarin\Sideroads.Android\MainActivity.cs(190,13,190,40): error CS0234: The type or namespace name 'Platform' does not exist in the namespace 'Xamarin.Essentials' (are you missing an assembly reference?)

The lines in question are

Xamarin.Essentials.Platform.Init(this, bundle);

and

Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

Basic Information

jfversluis commented 11 months ago

I see you mention that you're targeting Android 13 but can you double-check? I've had other reports and they let me know that targeting Android 13 fixed it for them.

Xamarin.Essentials 1.8 now has MonoAndroid13 as the target framework, your project should do the same :) that means you should also target API 33. See detailed instructions in this blog post.

After you have updated the target framework you might want to do some aggressive cleaning and rebuilding and maybe even delete your bin/obj folders to make sure nothing is left behind building against MonoAndroid10

mfeingol commented 11 months ago

That was it, thanks. UI showed using SDK version 13 (which I think is read/written from the manifest), but TargetFrameworkVersion in csproj was still set to 12.

jfversluis commented 11 months ago

Thanks for letting me know! I did update the GitHub releases here to make this a little more clearer as well.