Problem
Starting with API 37, Google's SDK Manager installs the platform to platforms/android-37.0 (package name platform-37.0_r01), but TryGetPlatformDirectoryFromApiLevel only tries platforms/android-37 and fails.
This causes XA5207 for customer projects targeting net11.0-android37.
Current behavior
In AndroidSdkInfo.cs:
public string? TryGetPlatformDirectoryFromApiLevel (string idOrApiLevel, AndroidVersions versions)
{
var id = versions.GetIdFromApiLevel (idOrApiLevel);
string? dir = GetPlatformDirectoryFromId (id); // \"platforms/android-37\"
if (Directory.Exists (dir))
return dir;
// Existing fallback: minor -> major (e.g. android-36.1 -> android-36)
// Guarded to NOT fall back for minor versions (dotnet/android#10720)
if (Version.TryParse (id, out var version) && version.Minor != 0)
return null;
// Integer fallback: also tries GetPlatformDirectory(37) -> \"android-37\" (same thing)
var level = versions.GetApiLevelFromId (id);
dir = level.HasValue ? GetPlatformDirectory (level.Value) : null;
if (dir != null && Directory.Exists (dir))
return dir;
return null; // <-- XA5207!
}
There is no fallback from android-{major} to android-{major}.0.
Proposed fix
When android-{id} doesn't exist and id is a pure integer (major-only), also try android-{id}.0:
// After existing checks fail, try major.0 fallback
if (int.TryParse (id, out _)) {
dir = GetPlatformDirectoryFromId (id + \".0\");
if (Directory.Exists (dir))
return dir;
}
Workaround
dotnet/android#11072 aligns the data so that platformID is \"37.0\" instead of \"37\", which makes the AndroidApiInfo.xml <Id> element 37.0. This means the first lookup will try android-37.0 directly.
However, the android-tools fallback is still valuable as a safety net for cases where the Id is just \"37\".
Context
Problem
Starting with API 37, Google's SDK Manager installs the platform to
platforms/android-37.0(package nameplatform-37.0_r01), butTryGetPlatformDirectoryFromApiLevelonly triesplatforms/android-37and fails.This causes XA5207 for customer projects targeting
net11.0-android37.Current behavior
In
AndroidSdkInfo.cs:There is no fallback from
android-{major}toandroid-{major}.0.Proposed fix
When
android-{id}doesn't exist andidis a pure integer (major-only), also tryandroid-{id}.0:Workaround
dotnet/android#11072 aligns the data so that
platformIDis\"37.0\"instead of\"37\", which makes theAndroidApiInfo.xml<Id>element37.0. This means the first lookup will tryandroid-37.0directly.However, the android-tools fallback is still valuable as a safety net for cases where the
Idis just\"37\".Context