.NET for Android error XA5207
Example messages
XA5207: Could not find android.jar for API Level 28. This means the Android SDK platform for API Level 28 is not installed. Either install it in the Android SDK Manager (Tools > Android > Android SDK Manager...), or change your .NET for Android project to target an API version that is installed.
Issue
In order to build a project, the Android SDK Platform matching the target API level must be installed.
Solution
Use the Android SDK Manager (Tools > Android > Android SDK Manager...) to install the Android SDK Platform for the desired API level. Alternatively you can install the missing API level by running the following command from a terminal or command prompt:
dotnet build -t:InstallAndroidDependencies -f net8.0-android "-p:AndroidSdkDirectory=<path to sdk directory>"
Part of the new .NET for Android system is when upgrading projects you will automatically be
upgraded to the latest API level. For example net7.0-android allowed you to target API 33,
but net8.0-android will automatically target API 34. If you want to keep your current
target API level you will need to add the 'uses-sdk' android:targetSdkVersion
to your AndroidManifest.xml
file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.companyname.myapp">
<uses-sdk android:targetSdkVersion="33">
<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" />
</manifest>
You might then need to run the InstallAndroidDependencies
target as mentioned above to ensure that the required API level is installed.