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 505 forks source link

Platform does not exist in the namespace Xamarin.Essentials - issue in a Xamarin.Android project that targets Android 9.0 [API 28] (JDK 8.1) #2056

Closed JayD2019 closed 1 year ago

JayD2019 commented 1 year ago
    Hi,  I have the same issue in a Xamarin.Android project that targets Android 9.0 

It worked fine for over a year until YESTERDAY Nov 1 2022. WHY now? The update number of the package has not changed. I have temporarily commented out the affected lines in MaInActivity.cs so that it compiles, but I need a fix. The app will not run without this call; Preferences in the app do not work for starters.

I read in https://github.com/xamarin/Essentials/issues/683 that target platform needs to be 8.1 (or higher I presumed). This now seems to have changed, as there seems to be no issue with the Platform section in Xamarin.Essentials if the Target version is set to 12.

However, I have to keep my target as 9 for development as the Android Designer does not work when targeting 11/12.
( https://github.com/xamarin/xamarin-android/wiki/JDK-11-Warning )
If I now have to change target platforms AND Jdk versions in order to debug my software and then switch back for design work, this is going to add an overhead, as I will need to change a whole host of Nu-Get packages each time also. Am I missing something? Please help.

Thanks J

Originally posted by @JayD2019 in https://github.com/xamarin/Essentials/issues/1964#issuecomment-1301519925

JayD2019 commented 1 year ago

There is no further update at https://github.com/xamarin/xamarin-android/wiki/JDK-11-Warning#jdk-11-caused-regressions with regards to either VS2019 or VS2022 , so I am "assuming" that this Xamarin.Android Designer issue has not been fixed as yet.

I am now using my aforementioned workaround using VS2019 on 2 different machines - one for design [API 28] one for build and debug [API 31] , but this is tedious and not conducive to meeting tight deadlines!! So please can we get a fix for this issue - thanks - unless the designer issue fix is expected VERY soon. And unless , as I asked previously , I am missing something.

JayD2019 commented 1 year ago

I have just read here: https://devblogs.microsoft.com/xamarin/whats-new-in-xamarin-and-visual-studio-2022/ that VS2022 has a working Android Designer. That's great but does not help me as I my main development machine is running Windows 7 and VS2022 does not support Win 7 apparently (not surprised). I am not planning on upgrading it to Win10 until I have to as we still have customers who run on Win 7, and we also still support WinCE and SQLCe products (with a variety of 3rd party SDKs) that require VS2008 ( which is nicely stable on Win 7 !!) . My Win 10 machine does not (currently) have the recommended spec for VS 2022.

At https://github.com/xamarin/xamarin-android/wiki/JDK-11-Warning#jdk-11-caused-regressions it states: "However, configuring [Visual Studio 2019]........ It will not be possible to target Android 12.0/API-31 and use e.g. the Xamarin.Android Designer at the same time. This will be fixed in a future release."

So, back to my ORIGINAL Question: Q: I need to know if there is a REAL PLAN to provide a fix for this issue in VS 2019 and if so WHEN?
If there is absolutely no intention to fix it, I need to know ASAP.

Thanks, J

PS/BTW: ( VS2022 came out circa Nov 2021 , and the JDK Warning URL was last updated Sept 2021 ? One would have thought that the article author might have known in Sept that the issue was fixed in VS2022 , yet there was no mention of it - which would have been helpful )

nguyennhatthuan commented 1 year ago

The same issue happen to me, still haven't had any solution yet :(

JayD2019 commented 1 year ago

The same issue happen to me, still haven't had any solution yet :(

Hi, I have given up on them fixing this issue. VS2019 is obsolete; clearly this is the plan. My Win 7 laptop just would not upgrade to Win10 - I tried everything - ( seems there is smth wrong with the OS , but it still works fine for supporting WIn 7.) Then my older laptop (WIn 10) died, so I was truly stuck! ( I am a contractor) Anyway, my boss bought me a new laptop for Xmas and I moved to VS2022 - and the Designer actually works!. But there may be other reasons why some are unable to use VS2022. IMO the way this has been handled (or is NOT being handled basically) is pretty poor! Good luck!

floresdwm commented 1 year ago

Me too, any news?

nguyennhatthuan commented 1 year ago

Me too, any news?

From my end, I've tried to migrate the Android project to use AndroidX, upgrading some nuget packages version to match the dependency, and the issue was sorted.

floresdwm commented 1 year ago

Me too, any news?

From my end, I've tried to migrate the Android project to use AndroidX, upgrading some nuget packages version to match the dependency, and the issue was sorted.

Thanks, me too. After upgrade some nuget packages, xamarin forms, essentials and add androidX packages using target android 13 and compiler version my problems was solved.

jfversluis commented 1 year ago

Looks like this is resolved by making sure you have all the latest updates and they're aligned. Thanks for all the input here!

AmaluThomas commented 5 months ago

Azure pipeline fails on upgrading "Xamarin.Essentials" package

Azure pipeline fails for android project after upgrading xamarin.essentails to 1.8.1.

1.8.1

Locally the project is building and image selection also work perfect.

This upgrade is required as select image and take photo is not working for android 13+.

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

Can some one suggest a solution.?