Home > Mobile >  How to set API level for MAUI projects
How to set API level for MAUI projects

Time:07-19

I am starting with dotnet maui and documentation is very poor at this point. I have existing project that targets older Android API level and have the Environment ready for this. When I try to build it, I get an error,

error XA5207: Could not find android.jar for API level 31. This means the Android SDK platform for API level 31 is not installed. Either install it in the Android SDK Manager (Tools > Open Android SDK Manager...), or change the Xamarin.Android project to target an API version that is installed

I couldn't find an option to change API level.

Edit: I could find a way to target newer versions and added that as an answer, but monikers older than 30 is still not being recognized and I am getting an error,

NETSDKZZZZ: Error getting pack version: Pack 'Microsoft.Android.Ref.30' was not present in workload manifests.

CodePudding user response:

I think the easiest and best solution is to actually install the requested SDK. This speaks of the target API level. I think the default for .NET MAUI apps right now is 31.

The minimum required API level to submit apps to the Google Play Store at this point is API level 30.

If you still want to change it, include a node like this in your csproj file: <TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">30</TargetPlatformVersion>

CodePudding user response:

For anyone trying to target newer API level:

Setting TargetPlatformVersion version in csproj seems to work for newer version (>30).

<TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">32</TargetPlatformVersion>
  • Related