We need to target Android v31 (NOT v34). What do we need to do in order to target Android v31 in our Maui app?
You can just use the <uses-sdk>
tag in the AndroidManifest.xml to do that:
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
The code above will make your app target android 31 but can still run on android 34.
If we attempt to build with TargetFrameworks set to "net8.0-android31.0" in the projects property file like this:
Please check the official document about OS version in TFMs. And I also tried it and add <TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">30</TargetPlatformVersion>
into the csproj file.
I get the following error in both ways:
31.0 is not a valid TargetPlatformVersion for Android. Valid versions include: 34.0
The .net8.0 can only set te target android framework version as 34. In addition, the target framework version just decides the Android SDK version when you code and compile.