Description
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
.NET 6.0.400
Description
When installing the android SDK using the InstallAndroidDependencies
target, the downloaded SDK is missing key tools, such as aapt and platform-tools
:
laurie@d95389ff63a7:/opt/android-sdk$ ls
platforms
This causes a build with the installed SDK to fail with error XA5300, since Xamarin discards your selected SDK directory when it thinks it's invalid. (perhaps a better error message would be great here, but not super important for this issue).
It would be great if this could be fixed since this target is very, very helpful for CI.
Steps to Reproduce
- Start a docker container with the
mcr.microsoft.com/dotnet/sdk:6.0
image. - Create a new user, make them a sudoer, and log into the user with
su
. - Install the android workload
sudo dotnet workload install android
. - Create a new net6.0-android project:
sudo dotnet new android -o example && cd example
. - Restore the project:
sudo dotnet restore ./example.csproj
- Invoke
InstallAndroidDependencies
to download the SDK:sudo dotnet msbuild ./example.csproj -t:InstallAndroidDependencies -p:AndroidSdkDirectory=/opt/android-sdk -p:AcceptAndroidSDKLicenses=true
- Attempt to use the new android SDK directory to build the project:
sudo dotnet publish -c Release -p:AndroidSdkDirectory=/opt/android-sdk
.
You will then receive the error:/usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/32.0.448/tools/Xamarin.Android.Tooling.targets(69,5): error XA5300: The Android SDK directory could not be found. Check that the Android SDK Manager in Visual Studio shows a valid installation. To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom path. [/home/laurie/example/example.csproj]
Did you find any workaround?
No workaround currently, I tried installing the SDK with sudo apt-get install -y android-sdk
, but unfortunately that SDK only targets API level 29, and we need API level 31 for net6.0-android.
Relevant log output
See comment for diagnostic logs of both InstallAndroidDepencies
and publish
.