Android framework version
net11.0-android (Preview)
Affected platform version
- Workload pack:
Microsoft.Android.Sdk.Linux/36.99.0-ci.main.189
- Manifest:
microsoft.net.sdk.android 36.99.0-ci.main.148/11.0.100-preview.5
- .NET SDK:
11.0.100-preview.5.26258.110
- Xamarin.Android:
16.0.0.513
- Host: Ubuntu 22.04 (Helix runner)
Description
Running InstallAndroidDependencies against a fresh, empty AndroidSdkDirectory / JavaSdkDirectory for a net11.0-android MAUI project bootstraps cmdline-tools and JDK successfully, but silently fails to install platforms;android-37.0 while still exiting with code 0. A subsequent dotnet build then fails with XA5207.
The relevant warning chain emitted during InstallAndroidDependencies (target exits 0 anyway):
Xamarin.Android.Tooling.targets(55,5): warning : An exception occurred while validating
the Java SDK installation in '<path>/jdk' … Could not find required file `jar` within
'<path>/jdk'; is this a valid JDK?
Xamarin.Android.Tooling.targets(55,5): warning XA5300: The Android SDK directory could
not be found.
Microsoft.Android.Sdk.Tooling.targets(35,5): warning XARAT7001:
System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Android.Tasks.ResolveAndroidTooling.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute()
Xamarin.Installer.Common.targets(19,3): warning : Dependency `platforms;android-37.0`
should have been installed but could not be resolved. You can attempt to install it
with: `<sdk>/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-37.0"`
Then on the next build:
Xamarin.Android.Tooling.targets(78,5): error XA5207: Could not find android.jar for
API level 37.0. … expected to be in `<sdk>/platforms/android-37.0/android.jar`.
Expected behaviour
InstallAndroidDependencies should either (a) successfully install the dependency it already knows is required (platforms;android-37.0), or (b) fail with a non-zero exit code when a declared dependency could not be installed. The current "warning + exit 0" behaviour makes the target unusable from automation — downstream tooling has no signal that the SDK is incomplete until a much later XA5207 build error.
Steps to Reproduce
mkdir -p /tmp/android-sdk /tmp/jdk
cat > rollback_maui.json <<JSON
{ "microsoft.net.sdk.android": "36.99.0-ci.main.148/11.0.100-preview.5" }
JSON
dotnet workload install maui-android --from-rollback-file rollback_maui.json
# Any trivial net11.0-android MAUI project will do:
dotnet new maui -n Repro && cd Repro
# edit .csproj so TargetFrameworks=net11.0-android only
dotnet msbuild Repro.csproj \
-t:InstallAndroidDependencies \
/p:AndroidSdkDirectory=/tmp/android-sdk \
/p:JavaSdkDirectory=/tmp/jdk \
/p:AcceptAndroidSdkLicenses=True \
/p:TargetFramework=net11.0-android
echo "Exit: $?" # 0
ls /tmp/android-sdk/platforms/ # no android-37.0/
dotnet build Repro.csproj -f net11.0-android \
/p:AndroidSdkDirectory=/tmp/android-sdk /p:JavaSdkDirectory=/tmp/jdk
# error XA5207: Could not find android.jar for API level 37.0
Did you find any workaround?
After InstallAndroidDependencies, run the command the warning suggests directly:
<sdk>/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-37.0"
That succeeds and the subsequent build works. But automation can't rely on the target's own exit code, since it returns 0 even when its declared dependency wasn't installed.
Relevant log output
Hit while bootstrapping a new MAUI Android perf scenario in dotnet/performance (PR dotnet/performance#5165) on a Helix Ubuntu 22.04 runner. Full Helix work item console log (ephemeral): the warning chain shown in Description is the exact unedited output. No binlog was uploaded by the work item; happy to attach one from a local repro on request.
Possibly related: #10187 (closed) — same XA5300 + XARAT7001 combo but a different root cause there (SDK was nested under the csproj dir). In our case android-sdk/ is a sibling of the csproj dir, not nested, so that fix doesn't apply.
Android framework version
net11.0-android (Preview)
Affected platform version
Microsoft.Android.Sdk.Linux/36.99.0-ci.main.189microsoft.net.sdk.android 36.99.0-ci.main.148/11.0.100-preview.511.0.100-preview.5.26258.11016.0.0.513Description
Running
InstallAndroidDependenciesagainst a fresh, emptyAndroidSdkDirectory/JavaSdkDirectoryfor anet11.0-androidMAUI project bootstraps cmdline-tools and JDK successfully, but silently fails to installplatforms;android-37.0while still exiting with code 0. A subsequentdotnet buildthen fails withXA5207.The relevant warning chain emitted during
InstallAndroidDependencies(target exits 0 anyway):Then on the next build:
Expected behaviour
InstallAndroidDependenciesshould either (a) successfully install the dependency it already knows is required (platforms;android-37.0), or (b) fail with a non-zero exit code when a declared dependency could not be installed. The current "warning + exit 0" behaviour makes the target unusable from automation — downstream tooling has no signal that the SDK is incomplete until a much laterXA5207build error.Steps to Reproduce
Did you find any workaround?
After
InstallAndroidDependencies, run the command the warning suggests directly:That succeeds and the subsequent build works. But automation can't rely on the target's own exit code, since it returns 0 even when its declared dependency wasn't installed.
Relevant log output
Hit while bootstrapping a new MAUI Android perf scenario in dotnet/performance (PR dotnet/performance#5165) on a Helix Ubuntu 22.04 runner. Full Helix work item console log (ephemeral): the warning chain shown in Description is the exact unedited output. No binlog was uploaded by the work item; happy to attach one from a local repro on request.
Possibly related: #10187 (closed) — same XA5300 + XARAT7001 combo but a different root cause there (SDK was nested under the csproj dir). In our case
android-sdk/is a sibling of the csproj dir, not nested, so that fix doesn't apply.