34.0 is not a valid TargetPlatformVersion for Android. Valid versions include: 35.0

Kim Strasser 1,321 Reputation points
2024-11-19T09:41:03.52+00:00

I changed the Target framework in my Android project properties from .NET 8.0 to .NET 9.0.

But then I get this error:

34.0 is not a valid TargetPlatformVersion for Android. Valid versions include: 35.0

Screenshot 2024-11-19 102241

Is it necessary to change the Target OS version to 35.0?

In addition, is it necessary to change the targetSdkVersion in AndroidManifest.xml to 35?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.6" android:versionCode="26">
	<uses-sdk android:minSdkVersion="31" android:targetSdkVersion="34" />

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2024-11-21T02:36:33.8166667+00:00

    Hello,

    Thanks for your feedback.

    As the documentation mentions, there is no need to specify an additional Android SDK version number when upgrading to .NET 9.

    It works now. I get no more errors. But I still get many warnings. Is it necessary to change something or can I ignore the warnings?

    This is because these Nuget Packages have not yet completed the migration to .net 9.0. You can wait for them to officially support .net 9.0 and then update them to resolve these warnings.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Graham McKechnie 441 Reputation points
    2024-11-24T00:26:59.0833333+00:00

    @Kim Strasser

    I just checked what I wrote previously. In a non Maui, Android-only app, you require <TargetFramework>net9.0-android35</TargetFramework>.

    I think that may have only applied if you were using .net8. I just created a new .Net 9 Android-only app from the supplied template, and it uses net9.0-android. When you check the androidmanifest.xml in the obj\Release\net9.0-android\android\manifest folder after building the app the androidmanifest.xml file shows the following <uses-sdk android:minSdkVersion="27" android:targetSdkVersion="35"/>, so I'm going to assume that the Maui template does the same.

    Note I manually changed the minSdkVersion to 27. I think it will likely remain that way until Android 16 is released, and then it will probably require net9.0-android36, as the default would still be android35. Apologies for the misinformation.

    0 comments No comments

  2. Nikos Kastellanos 0 Reputation points
    2024-12-03T10:30:27.23+00:00

    That's a bug in net9.0.

    I had a project with targetSdk 32, because I am building VR apps for native meta/oculus and android 32 is a requirement there. The target framework of the project is
    '<TargetFramework>net8.0-android32</TargetFramework>'.
    I updated VS2022 a couple of days ago, and today I got an error that 34.0 is required and 32.0 is not supported. I've tried a couple of thing, and when I set it to net9, I got an error that target sdk has to be 35. Even 'net9.0-android34' would not work.
    34 and 35 are the defaults for net8 and net9. According to the documentation you should be able to target as low as sdk21. But net9 doesn't like anything other than the defaults.
    I assume the original poster, had 'net8.0-android34', and when he upgraded to net9 from the VS properties, it .csproj was changed to 'net9.0-android34'.

    I removed net9.0 sdk and everything went back to normal and now I can build with 'net8.0-android32'. Note that, I don't know why VS added net9. I certainty didn't see a prompt or a warning. I had a similar issue a couple of days ago where I couldn't publish a Blazor-wasm app and had to remove the net9 wasm tools.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.