I am building an app using .NET Android (formarly Xamarin.Android), but now it's not Xamarin and it's not MAUI, I can find very little to no documentation on this native Android C# development, I wonder why, considering the performance difference between this and MAUI is like day and night... Anyways, somehow I can't set TargetSDK version, or what I set is not being used in the build process by all the assemblies, something weird is happening and I don't really know what.
I tried to put the target SDK every way I could imagine, like this in the csproj:
<SupportedOSPlatformVersion>26.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion>26</TargetPlatformMinVersion>
<TargetOSPlatformVersion>34</TargetOSPlatformVersion>
<TargetPlatformVersion>34</TargetPlatformVersion>
<AndroidTargetSdkVersion>34</AndroidTargetSdkVersion>
Like this:
<TargetFramework>net8.0-android34.0</TargetFramework>
Like this, in Android Manifest:
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="34" />
and these same numbers inside the application tag too.
Whatever I do, I get this warning at build time, and the resulting bundle has target sdk = 28. The warning is complaining about some assembly inside the Xamarin tooling on which everything else I suppose depends, but shouldn't it target the same thing I target my code? If not, how to fix this issue?
This is what I get when doing the release build:
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.43\targets\Microsoft.Android.Sdk.Tooling.targets(69,5): warning XA1006: The TargetFram eworkVersion (Android API level 34) is higher than the targetSdkVersion (28). Please increase the
android:targetSdkVersion
in theAndroidManifest.xm l
so that the API levels match. [C:\Users\xdr\source\repos\movsar\chldr\src\client\chldr_android\chldr_android.csproj]
There is no place at all in my code where I set 28 to anything!
Yes, to fix the issue, you may need to add the following to your AndroidManifest.xml
:
<uses-sdk android:targetSdkVersion="34" />
As a summary:
targetSdkVersion
is what your API Level app Supports, this can be different from compileSdkVersion
since you can use runtime checks to see which API level you are on.
minSdkVersion
is the minimum platform which supports.