dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 533 forks source link

Could not determine API level for $(TargetFrameworkVersion) of 'v14.0' #9400

Closed vsfeedback closed 4 weeks ago

vsfeedback commented 1 month ago

This issue has been moved from a ticket on Developer Community.


With my current Xamarin project, I need to target Android SDK level 34. I changed the level to 34 in manifest file (Android 14.0, API Level 34), but during Archiving, it targets older level 33. I checked Compile version and it's set to Android 13.0 and I do not have option to select 14.0.

The TargetFrameworkVersion (Android API level 33) is lower than the targetSdkVersion (34). Please increase the $(TargetFrameworkVersion) or decrease the android:targetSdkVersion in the AndroidManifest.xml so that the API levels match.

If I increase the number to v14.0, v14.0, I get

Could not determine API level for $(TargetFrameworkVersion) of 'v14.0'

I have SDK Platform 34 installed from Android SDK Manager.

Pls help. Thank you.


Original Comments

Feedback Bot on 7/28/2024, 07:49 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Gian Salaritan on 9/27/2024, 08:08 AM:

Same scenario with me, any update on this?

Dean Ellis [MSFT] on 10/7/2024, 06:24 AM:

I will check but I believe Xamarin projects are now out of support.
You will need to upgrade to .net 8 in order to target newer sdk platforms.

dellis1972 commented 1 month ago

@tondat this looks like a bug in the Archive feature on VS?

jonathanpeppers commented 4 weeks ago

Xamarin.Android never supported $(TargetFrameworkVersion) of v14.0, a view of our legacy, d17-5 branch:

https://github.com/dotnet/android/blob/e8d4d9b50c1bc511fe8bd5ce7fc40025ba4465b3/Configuration.props#L33

13.0 / API 33 was the latest.

If you are trying to target API 34 (and Android 14.0) in Xamarin.Android, you'll probably want to update your AndroidManifest.xml to have:

android:targetSdkVersion="34"

But you'll end up with build warnings like the one listed above.

Really, the only choice is to ignore it, there is no plan to add API 34 to Xamarin.Android, an end-of-life product:

jonathanpeppers commented 4 weeks ago

Closing, if this really is a Xamarin.Android project, your options are:

Let us know if we missed something, thanks!

jonpryor commented 4 weeks ago

Xamarin.Android 13.2 allows targeting API-34, but not using API-34: https://learn.microsoft.com/en-us/previous-versions/xamarin/android/release-notes/13/13.2#target-api34

Targeting API-34 will result in an XA1008 warning:

…/Xamarin.Android.Legacy.targets(348,5): warning XA1008: The TargetFrameworkVersion (Android API level 33) is lower than the targetSdkVersion (34). Please increase the $(TargetFrameworkVersion) or decrease the android:targetSdkVersion in the AndroidManifest.xml so that the API levels match.

which is what the customer is reporting.

If you must remain on Xamarin.Android, just ignore the XA1008 warning.

Note, however, that if (when?) Android ever requires 16 KB alignment of native libraries, you will need to migrate to .NET 9 or later. See also: