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

Kim Strasser 1,096 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" />

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,696 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 45,181 Reputation points Microsoft Vendor
    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.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Graham McKechnie 421 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

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.